本文整理汇总了PHP中get_object_by_manager_and_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_object_by_manager_and_id函数的具体用法?PHP get_object_by_manager_and_id怎么用?PHP get_object_by_manager_and_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_object_by_manager_and_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getObject
/**
* Return object
*
* @param void
* @return ApplicationDataObject
*/
function getObject()
{
if (is_null($this->object)) {
$this->object = get_object_by_manager_and_id($this->getObjectId(), $this->getObjectManager());
}
return $this->object;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:13,代码来源:ObjectReminder.class.php
示例2: getObject
/**
* Return associated object
*
* @param void
* @return ProjectDataObject
*/
function getObject()
{
if (is_null($this->object)) {
$this->object = get_object_by_manager_and_id($this->getId(), get_class($this->manager()));
}
// if
return $this->object;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:14,代码来源:ObjectHandin.class.php
示例3: getOtherObject
/**
* Return object connected with this action, that is not equal to the one received
*
* @access public
* @param ProjectDataObject $object
* @return ProjectDataObject
*/
function getOtherObject($object)
{
if (get_class($object->manager()) != $this->getObjectManager() || $object->getObjectId() != $this->getObjectId()) {
return get_object_by_manager_and_id($this->getObjectId(), $this->getObjectManager());
} else {
return get_object_by_manager_and_id($this->getRelObjectId(), $this->getRelObjectManager());
}
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:15,代码来源:LinkedObject.class.php
示例4: getObjectsByTemplate
/**
* Returns all Objects of a Template
*
* @param integer $template_id
* @return array
*/
static function getObjectsByTemplate($template_id)
{
$all = self::findAll(array('conditions' => array('`template_id` = ?', $template_id)));
if (!is_array($all)) {
return array();
}
$objs = array();
foreach ($all as $obj) {
$objs[] = get_object_by_manager_and_id($obj->getObjectId(), $obj->getObjectManager());
}
return $objs;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:18,代码来源:TemplateObjects.class.php
示例5: delete_tag
/**
* Delete tag URL
*
* @access public
* @param void
* @return null
*/
function delete_tag()
{
if (!logged_user()->isAdministrator()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$tag_name = array_var($_GET, 'tag_name');
$object_id = array_var($_GET, 'object_id');
$manager_class = array_var($_GET, 'manager_class');
$obj = get_object_by_manager_and_id($object_id, $manager_class);
$obj->deleteTag($tag_name);
$this->redirectToReferer('');
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:21,代码来源:TagController.class.php
示例6: doSearch
/**
* Do the search
*
* @param string $conditions
* @param integer $limit
* @param integer $offset
* @return array
*/
function doSearch($conditions, $limit = null, $offset = null)
{
$table_name = SearchableObjects::instance()->getTableName(true);
$limit_string = '';
if ((int) $limit > 0) {
$offset = (int) $offset > 0 ? (int) $offset : 0;
$limit_string = " LIMIT {$offset}, {$limit}";
}
// if
$where = '';
if (trim($conditions) != '') {
$where = "WHERE {$conditions}";
}
$sql = "SELECT `rel_object_manager`, `rel_object_id` FROM {$table_name} {$where} {$limit_string}";
$result = DB::executeAll($sql);
if (!is_array($result)) {
return null;
}
$loaded = array();
$objects = array();
foreach ($result as $row) {
$manager_class = array_var($row, 'rel_object_manager');
$object_id = array_var($row, 'rel_object_id');
if (!isset($loaded[$manager_class . '-' . $object_id]) || !$loaded[$manager_class . '-' . $object_id]) {
if (class_exists($manager_class)) {
$object = get_object_by_manager_and_id($object_id, $manager_class);
if ($object instanceof ProjectDataObject) {
$loaded[$manager_class . '-' . $object_id] = true;
$objects[] = $object;
}
// if
}
// if
}
// if
}
// foreach
return count($objects) ? $objects : null;
}
开发者ID:469306621,项目名称:Languages,代码行数:47,代码来源:SearchableObjects.class.php
示例7: mark_as_ham
function mark_as_ham()
{
ajx_current("empty");
$csvids = array_var($_GET, 'ids');
$ids = explode(",", $csvids);
$succ = 0;
$err = 0;
foreach ($ids as $id) {
list($manager, $objid) = explode(":", $id);
$mail = get_object_by_manager_and_id($objid, $manager);
if ($mail instanceof MailContent) {
$mail->setState(0);
$mail->save();
$succ++;
} else {
$err++;
}
}
if ($err <= 0) {
flash_success(lang('success mark as ham', $succ));
} else {
flash_error(lang('error mark as ham', $succ));
}
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:24,代码来源:MailController.class.php
示例8: getTasksAndMilestones
private function getTasksAndMilestones($page, $objects_per_page, $tag = null, $order = null, $order_dir = null, $parent_task_id = null, $project = null, $tasksAndOrMilestones = 'both')
{
if (!$parent_task_id || !is_numeric($parent_task_id)) {
$parent_task_id = 0;
}
$parent_string = " AND parent_id = {$parent_task_id} ";
$queries = ObjectController::getDashboardObjectQueries($project, $tag);
if ($tasksAndOrMilestones == 'both') {
$query = $queries['ProjectTasks'] . $parent_string . " UNION " . $queries['ProjectMilestones'];
} else {
if ($tasksAndOrMilestones == 'tasks') {
$query = $queries['ProjectTasks'] . $parent_string;
} else {
$query = $queries['ProjectMilestones'];
}
}
if ($order) {
$query .= " order by " . $order . " ";
if ($order_dir) {
$query .= " " . $order_dir . " ";
}
} else {
$query .= " order by last_update desc ";
}
if ($page && $objects_per_page) {
$start = ($page - 1) * $objects_per_page;
$query .= " limit " . $start . "," . $objects_per_page . " ";
} else {
if ($objects_per_page) {
$query .= " limit " . $objects_per_page;
}
}
$res = DB::execute($query);
$objects = array();
if (!$res) {
return $objects;
}
$rows = $res->fetchAll();
if (!$rows) {
return $objects;
}
$i = 1;
foreach ($rows as $row) {
$manager = $row['object_manager_value'];
$id = $row['oid'];
if ($id && $manager) {
$obj = get_object_by_manager_and_id($id, $manager);
if ($obj->canView(logged_user())) {
$dash_object = $obj->getDashboardObject();
// $dash_object['id'] = $i++;
$objects[] = $dash_object;
}
}
//if($id && $manager)
}
//foreach
return $objects;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:58,代码来源:TaskController.class.php
示例9: add
/**
* Add comment
*
* Through this controller only logged users can post (no anonymous comments here)
*
* @param void
* @return null
*/
function add()
{
$this->setTemplate('add_comment');
$object_id = get_id('object_id');
$object_manager = array_var($_GET, 'object_manager');
if (!is_valid_function_name($object_manager)) {
flash_error(lang('invalid request'));
$this->redirectToUrl(active_project()->getOverviewUrl());
}
// if
$object = get_object_by_manager_and_id($object_id, $object_manager);
if (!$object instanceof ProjectDataObject || !$object->canComment(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToUrl(active_project()->getOverviewUrl());
}
// if
$comment = new Comment();
$comment_data = array_var($_POST, 'comment');
tpl_assign('comment_form_object', $object);
tpl_assign('comment', $comment);
tpl_assign('comment_data', $comment_data);
if (is_array($comment_data)) {
try {
try {
$attached_files = ProjectFiles::handleHelperUploads(active_project());
} catch (Exception $e) {
$attached_files = null;
}
// try
$comment->setFromAttributes($comment_data);
$comment->setRelObjectId($object_id);
$comment->setRelObjectManager($object_manager);
if (!logged_user()->isMemberOfOwnerCompany()) {
$comment->setIsPrivate(false);
}
// if
if ($object instanceof ProjectMessage || $object instanceof ProjectFile) {
if ($object->getIsPrivate()) {
$comment->setIsPrivate(true);
}
// if
}
// if
DB::beginWork();
$comment->save();
if (is_array($attached_files)) {
foreach ($attached_files as $attached_file) {
$comment->attachFile($attached_file);
}
// foreach
}
// if
ApplicationLogs::createLog($comment, active_project(), ApplicationLogs::ACTION_ADD);
// Subscribe user to message (if $object is message)
if ($object instanceof ProjectMessage) {
if (!$object->isSubscriber(logged_user())) {
$object->subscribeUser(logged_user());
}
// if
}
// if
DB::commit();
flash_success(lang('success add comment'));
$redirect_to = $comment->getViewUrl();
if (!is_valid_url($redirect_to)) {
$redirect_to = $object->getViewUrl();
}
// if
$this->redirectToUrl($redirect_to);
} catch (Exception $e) {
DB::rollback();
tpl_assign('error', $e);
}
// try
}
// if
}
开发者ID:ukd1,项目名称:Project-Pier,代码行数:85,代码来源:CommentController.class.php
示例10: doSearch
/**
* Do the search
*
* @param string $conditions
* @param integer $limit
* @param integer $offset
* @return array
*/
function doSearch($conditions, $limit = null, $offset = null, $search_for = '')
{
$table_name = SearchableObjects::instance()->getTableName(true);
//$tags_table_name = Tags::instance()->getTableName();
$limit_string = '';
if ((int) $limit > 0) {
$offset = (int) $offset > 0 ? (int) $offset : 0;
$limit_string = " LIMIT {$offset}, {$limit}";
}
// if
$where = '';
if (trim($conditions) != '') {
$where = "WHERE {$conditions}";
}
$sql = "SELECT distinct `rel_object_manager`, `rel_object_id` FROM {$table_name} {$where} ORDER BY `rel_object_id` DESC {$limit_string}";
$result = DB::executeAll($sql);
if (!is_array($result)) {
return null;
}
$new_where = "'1' = '2' ";
foreach ($result as $row) {
$manager_class = array_var($row, 'rel_object_manager');
$object_id = array_var($row, 'rel_object_id');
$new_where .= " OR (rel_object_manager = '" . $manager_class . "' AND rel_object_id = '" . $object_id . "')";
}
$new_where = " AND (" . $new_where . ')';
$sql = "SELECT `rel_object_manager`, `rel_object_id`, `column_name`, `content` FROM {$table_name} {$where} {$new_where} ORDER BY `rel_object_id`";
$result = DB::executeAll($sql);
if (!is_array($result)) {
return null;
}
$loaded = array();
$objects = array();
foreach ($result as $row) {
$manager_class = array_var($row, 'rel_object_manager');
$object_id = array_var($row, 'rel_object_id');
if (!isset($loaded[$manager_class . '-' . $object_id])) {
if (class_exists($manager_class)) {
$object = get_object_by_manager_and_id($object_id, $manager_class);
if ($object instanceof ApplicationDataObject) {
$objects[] = array('object' => $object, 'context' => array(array('context' => SearchableObjects::getContext(array_var($row, 'content'), $search_for), 'column_name' => array_var($row, 'column_name'))));
$loaded[$manager_class . '-' . $object_id] = count($objects) - 1;
}
// if
}
// if
} else {
$objects[$loaded[$manager_class . '-' . $object_id]]['context'][] = array('context' => SearchableObjects::getContext(array_var($row, 'content'), $search_for), 'column_name' => array_var($row, 'column_name'));
}
// if
}
// foreach
return count($objects) ? $objects : null;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:62,代码来源:SearchableObjects.class.php
示例11: add_to
function add_to()
{
if (!can_manage_templates(logged_user())) {
flash_error(lang("no access permissions"));
ajx_current("empty");
return;
}
$manager = array_var($_GET, 'manager');
$id = get_id();
$object = get_object_by_manager_and_id($id, $manager);
$template_id = array_var($_GET, 'template');
if ($template_id) {
$template = COTemplates::findById($template_id);
if ($template instanceof COTemplate) {
try {
DB::beginWork();
$template->addObject($object);
DB::commit();
flash_success(lang('success add object to template'));
ajx_current("start");
} catch (Exception $e) {
DB::rollback();
flash_error($e->getMessage());
}
}
}
tpl_assign('templates', COTemplates::findAll());
tpl_assign("object", $object);
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:29,代码来源:TemplateController.class.php
示例12: array
$sub_wss[] = $w;
}
}
}
$sub_wss_csv = array();
foreach ($sub_wss as $sub_ws) {
$sub_wss_csv[] = $sub_ws->getId();
}
$linked_object_actions = array();
$activities = ApplicationLogs::getLastActivities($ws, active_tag(), user_config_option('activity widget elements'));
$groups = array();
$first = null;
$obj_wss_cache = array();
foreach ($activities as $act) {
$user = Users::findById($act->getCreatedById());
$object = get_object_by_manager_and_id($act->getRelObjectId(), $act->getRelObjectManager());
if (!$user || !$object) {
continue;
}
/* if ($user && $object && $act->getAction() != 'login' && $act->getAction() != 'logout'
&& !can_access($user, $object, ACCESS_LEVEL_READ)) continue;
*/
$avatar_url = $user->getAvatarUrl();
$date = $act->getCreatedOn() instanceof DateTimeValue ? friendly_date($act->getCreatedOn()) : lang('n/a');
$dontshow = false;
$tmp_id = '';
if ($act->getAction() == ApplicationLogs::ACTION_LINK || $act->getAction() == ApplicationLogs::ACTION_UNLINK) {
$tmp_id = $act->getRelObjectManager() . ":" . $act->getRelObjectId();
foreach ($linked_object_actions as $loa) {
if ($loa['action'] == $act->getAction() && ($loa['source'] == $tmp_id && $loa['dest'] == $act->getLogData() || $loa['source'] == $act->getLogData() && $loa['dest'] == $tmp_id)) {
$dontshow = true;
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:31,代码来源:widget_activity.php
示例13: getObject
/**
* Return object connected with this action
*
* @access public
* @param void
* @return ProjectDataObject
*/
function getObject()
{
return get_object_by_manager_and_id($this->getRelObjectId(), $this->getRelObjectManager());
}
开发者ID:469306621,项目名称:Languages,代码行数:11,代码来源:Comment.class.php
示例14: detach_from_object
/**
* Detach file from related object
*
* @param void
* @return null
*/
function detach_from_object()
{
$manager_class = array_var($_GET, 'manager');
$object_id = get_id('object_id');
$file_id = get_id('file_id');
$object = get_object_by_manager_and_id($object_id, $manager_class);
if (!$object instanceof ProjectDataObject) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
$file = ProjectFiles::findById($file_id);
if (!$file instanceof ProjectFile) {
flash_error(lang('file dnx'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
$attached_file = AttachedFiles::findById(array('rel_object_manager' => $manager_class, 'rel_object_id' => $object_id, 'file_id' => $file_id));
// findById
if (!$attached_file instanceof AttachedFile) {
flash_error(lang('file not attached to object'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
try {
DB::beginWork();
$attached_file->delete();
DB::commit();
flash_success(lang('success detach file'));
} catch (Exception $e) {
flash_error(lang('error detach file'));
DB::rollback();
}
// try
$this->redirectToReferer($object->getObjectUrl());
}
开发者ID:469306621,项目名称:Languages,代码行数:42,代码来源:FilesController.class.php
示例15: add_timespan
function add_timespan()
{
if (!can_manage_time(logged_user(), true)) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$object_id = get_id('object_id');
$object_manager = array_var($_GET, 'object_manager');
if (!is_valid_function_name($object_manager)) {
flash_error(lang('invalid request'));
ajx_current("empty");
return;
}
// if
$object = get_object_by_manager_and_id($object_id, $object_manager);
if (!$object instanceof ProjectDataObject || !$object->canAddTimeslot(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
$timeslot_data = array_var($_POST, 'timeslot');
$hours = array_var($timeslot_data, 'time');
if (strpos($hours, ',') && !strpos($hours, '.')) {
$hours = str_replace(',', '.', $hours);
}
$timeslot = new Timeslot();
$dt = DateTimeValueLib::now();
$dt2 = DateTimeValueLib::now();
$timeslot->setEndTime($dt);
$dt2 = $dt2->add('h', -$hours);
$timeslot->setStartTime($dt2);
$timeslot->setDescription(array_var($timeslot_data, 'description'));
$timeslot->setUserId(logged_user()->getId());
$timeslot->setObjectManager($object_manager);
$timeslot->setObjectId($object_id);
/* Billing */
$billing_category_id = logged_user()->getDefaultBillingId();
$project = $object->getProject();
$timeslot->setBillingId($billing_category_id);
$hourly_billing = $project->getBillingAmount($billing_category_id);
$timeslot->setHourlyBilling($hourly_billing);
$timeslot->setFixedBilling($hourly_billing * $hours);
$timeslot->setIsFixedBilling(false);
try {
DB::beginWork();
$timeslot->save();
ApplicationLogs::createLog($timeslot, $timeslot->getWorkspaces(), ApplicationLogs::ACTION_OPEN);
DB::commit();
flash_success(lang('success create timeslot'));
ajx_current("reload");
} catch (Exception $e) {
DB::rollback();
ajx_current("empty");
flash_error($e->getMessage());
}
// try
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:59,代码来源:TimeslotController.class.php
示例16: do_share
function do_share()
{
$share_data = array_var($_POST, 'share_data');
if (is_array($share_data)) {
$obj = get_object_by_manager_and_id(array_var($share_data, 'object_id'), array_var($share_data, 'object_manager'));
$emails = array_var($_POST, 'emails');
$companies = array_var($_POST, 'companiesId');
if (!is_array($emails) || !count($emails)) {
flash_error(lang('must specify recipients'));
ajx_current("empty");
return;
}
$people = array();
foreach ($emails as $k => $email) {
// Retrieve users to notify
$lt_pos = strpos_utf($email, '<');
if ($lt_pos !== FALSE) {
// only email address
$email = substr_utf($email, $lt_pos + 1);
$email = str_replace('>', '', $email);
}
if (trim($email) != '') {
$user = Users::findOne(array('conditions' => "`email` = '" . $email . "'"));
if (!$user instanceof User) {
// User not exists -> create one with minimum permissions
try {
DB::beginWork();
$user = $this->createMinimumUser($email, $companies[$k]);
DB::commit();
} catch (Exception $e) {
DB::rollback();
}
}
if ($user instanceof User) {
$people[] = $user;
$canWrite = array_var($share_data, 'allow_edit');
if ($canWrite && !$obj->canEdit($user) || !$obj->canView($user)) {
$this->setObjUserPermission($user, $obj, $canWrite);
}
$this->saveSharedObject($obj, $user);
}
}
}
Notifier::shareObject($obj, $people);
flash_success(lang("success sharing object"));
ajx_current("back");
}
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:48,代码来源:ObjectController.class.php
示例17: add
/**
* Add comment
*
* Through this controller only logged users can post (no anonymous comments here)
*
* @param void
* @return null
*/
function add()
{
$this->setTemplate('add_comment');
$object_id = get_id('object_id');
$object_manager = array_var($_GET, 'object_manager');
if (!is_valid_function_name($object_manager)) {
flash_error(lang('invalid request'));
$this->redirectToUrl(active_project()->getOverviewUrl());
}
// if
$object = get_object_by_manager_and_id($object_id, $object_manager);
if (!$object instanceof ProjectDataObject || !$object->canComment(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToUrl(active_project()->getOverviewUrl());
}
// if
$comment = new Comment();
$comment_data = array_var($_POST, 'comment');
if (!is_array($comment_data)) {
$comment_data = array('text' => '', 'is_private' => config_option('default_private', false));
// array
}
// if
tpl_assign('comment_form_object', $object);
tpl_assign('comment', $comment);
tpl_assign('comment_data', $comment_data);
if (is_array($comment_data)) {
try {
try {
$attached_files = ProjectFiles::handleHelperUploads(active_project());
} catch (Exception $e) {
$attached_files = null;
}
// try
$comment->setFromAttributes($comment_data);
$comment->setRelObjectId($object_id);
$comment->setRelObjectManager($object_manager);
if (!logged_user()->isMemberOfOwnerCompany()) {
$comment->setIsPrivate(false);
}
// if
if ($object instanceof ProjectMessage || $object instanceof ProjectFile) {
if ($object->getIsPrivate()) {
$comment->setIsPrivate(true);
}
// if
}
// if
DB::beginWork();
$comment->save();
if (is_array($attached_files)) {
foreach ($attached_files as $attached_file) {
$comment->attachFile($attached_file);
}
// foreach
}
// if
ApplicationLogs::createLog($comment, active_project(), ApplicationLogs::ACTION_ADD);
// Subscribe user to object (if $object is subscribible)
if ($object->isSubscribable()) {
if (!$object->isSubscriber(logged_user())) {
$object->subscribeUser(logged_user());
}
// if
}
// if
DB::commit();
// Try to send notification on comments other than Messages (messages already managed by subscription)
if (!$comment->getObject() instanceof ProjectMessage) {
// Try to send notifications but don't break submission in case of an error
// define all the users to be notified - here all project users, from all companies.
// Restrictions if comment is private is taken into account in newOtherComment()
try {
$notify_people = array();
$project_companies = active_project()->getCompanies();
foreach ($project_companies as $project_company) {
$company_users = $project_company->getUsersOnProject(active_project());
if (is_array($company_users)) {
foreach ($company_users as $company_user) {
if (array_var($comment_data, 'notify_company_' . $project_company->getId()) == 'checked' || array_var($comment_data, 'notify_user_' . $company_user->getId())) {
$notify_people[] = $company_user;
}
// if
}
// if
}
// if
}
// if
Notifier::newOtherComment($comment, $notify_people);
// send notification email...
} catch (Exception $e) {
//.........这里部分代码省略.........
开发者ID:federosky,项目名称:ProjectPier-Core,代码行数:101,代码来源:CommentController.class.php
示例18: add
/**
* Add comment
*
* Through this controller only logged users can post (no anonymous comments here)
*
* @param void
* @return null
*/
function add()
{
$this->setTemplate('add_comment');
$object_id = get_id('object_id');
$object_manager = array_var($_GET, 'object_manager');
if (!is_valid_function_name($object_manager)) {
flash_error(lang('invalid request'));
ajx_current("empty");
return;
}
// if
$object = get_object_by_manager_and_id($object_id, $object_manager);
if (!$object instanceof ProjectDataObject || !$object->canComment(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
$comment = new Comment();
$comment_data = array_var($_POST, 'comment');
tpl_assign('comment_form_object', $object);
tpl_assign('comment', $comment);
tpl_assign('comment_data', $comment_data);
if (is_array($comment_data)) {
try {
try {
$attached_files = ProjectFiles::handleHelperUploads(active_or_personal_project());
} catch (Exception $e) {
$attached_files = null;
}
// try
$comment->setFromAttributes($comment_data);
$comment->setRelObjectId($object_id);
$comment->setRelObjectManager($object_manager);
// if(!logged_user()->isMemberOfOwnerCompany()) {
$comment->setIsPrivate(false);
// } // if
DB::beginWork();
$comment->save();
if (is_array($attached_files)) {
foreach ($attached_files as $attached_file) {
$comment->attachFile($attached_file);
}
// foreach
}
// if
// Subscribe user to object
if (!$object->isSubscriber(logged_user())) {
$object->subscribeUser(logged_user());
}
// if
if (strlen($comment->getText()) < 100) {
$comment_head = $comment->getText();
} else {
$lastpos = strpos($comment->getText(), " ", 100);
if ($lastpos === false) {
$comment_head = $comment->getText();
} else {
$comment_head = substr($comment->getText(), 0, $lastpos) . "...";
}
}
$comment_head = html_to_text($comment_head);
ApplicationLogs::createLog($object, $object->getWorkspaces(), ApplicationLogs::ACTION_COMMENT, false, null, true, $comment_head);
DB::commit();
flash_success(lang('success add comment'));
ajx_current("reload");
} catch (Exception $e) {
DB::rollback();
ajx_current("empty");
flash_error($e->getMessage());
}
// try
}
// if
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:83,代码来源:CommentController.class.php
示例19: getActivityData
function getActivityData()
{
$user = Users::findById($this->getCreatedById());
$object = get_object_by_manager_and_id($this->getRelObjectId(), $this->getRelObjectManager());
if (!$user) {
return false;
}
$icon_class = "";
if ($object instanceof ProjectFile) {
$path = explode("-", str_replace(".", "_", str_replace("/", "-", $object->getTypeString())));
$acc = "";
foreach ($path as $p) {
$acc .= $p;
$icon_class .= ' ico-' . $acc;
$acc .= "-";
}
}
if ($object) {
$object_link = '<a style="font-weight:bold" href="' . $object->getObjectUrl() . '"> ' . '<span style="padding: 1px 0 3px 18px;" class="db-ico ico-unknown ico-' . $object->getObjectTypeName() . $icon_class . '"/>' . clean($object->getObjectName()) . '</a>';
} else {
$object_link = clean($this->getObjectName()) . ' ' . lang('object is deleted');
}
switch ($this->getAction()) {
case ApplicationLogs::ACTION_EDIT:
case ApplicationLogs::ACTION_ADD:
case ApplicationLogs::ACTION_DELETE:
case ApplicationLogs::ACTION_TRASH:
case ApplicationLogs::ACTION_UNTRASH:
case ApplicationLogs::ACTION_OPEN:
case ApplicationLogs::ACTION_CLOSE:
case ApplicationLogs::ACTION_ARCHIVE:
case ApplicationLogs::ACTION_UNARCHIVE:
case ApplicationLogs::ACTION_READ:
case ApplicationLogs::ACTION_DOWNLOAD:
case ApplicationLogs::ACTION_CHECKIN:
case ApplicationLogs::ACTION_CHECKOUT:
if ($object) {
return lang('activity ' . $this->getAction(), lang('the ' . $object->getObjectTypeName()), $user->getDisplayName(), $object_link);
} else {
return lang('activity ' . $this->getAction(), lang('the ' . $this->getRelObjectManager()), $user->getDisplayName(), $object_link);
}
case ApplicationLogs::ACTION_SUBSCRIBE:
case ApplicationLogs::ACTION_UNSUBSCRIBE:
$user_ids = explode(",", $this->getLogData());
if (count($user_ids) < 8) {
$users_str = "";
foreach ($user_ids as $usid) {
$su = Users::findById($usid);
if ($su instanceof User) {
$users_str .= '<a style="font-weight:bold" href="' . $su->getObjectUrl() . '"> <span style="padding: 0 0 3px 18px;" class="db-ico ico-unknown ico-user"/>' . clean($su->getObjectName()) . '</a>, ';
}
}
if (count($user_ids) == 1) {
$users_text = substr(trim($users_str), 0, -1);
} else {
$users_text = lang('x users', count($user_ids), ": {$users_str}");
}
} else {
$users_text = lang('x users', count($user_ids), "");
}
if ($object) {
return lang('activity ' . $this->getAction(), lang('the ' . $object->getObjectTypeName()), $user->getDisplayName(), $object_link, $users_text);
} else {
return lang('activity ' . $this->getAction(), lang('the ' . $this->getRelObjectManager()), $user->getDisplayName(), $object_link, $users_text);
}
case ApplicationLogs::ACTION_COMMENT:
if ($object) {
return lang('activity ' . $this->getAction(), lang('the ' . $object->getObjectTypeName()), $user->getDisplayName(), $object_link, $this->getLogData());
} else {
return lang('activity ' . $this->getAction(), lang('the ' . $this->getRelObjectManager()), $user->getDisplayName(), $object_link, $this->getLogData());
}
case ApplicationLogs::ACTION_LINK:
case ApplicationLogs::ACTION_UNLINK:
$exploded = explode(":", $this->getLogData());
$linked_object = get_object_by_manager_and_id($exploded[1], $exploded[0]);
if ($linked_object instanceof ApplicationDataObject) {
$icon_class = "";
if ($linked_object instanceof ProjectFile) {
$path = explode("-", str_replace(".", "_", str_replace("/", "-", $linked_object->getTypeString())));
$acc = "";
foreach ($path as $p) {
$acc .= $p;
$icon_class .= ' ico-' . $acc;
$acc .= "-";
}
}
$linked_object_link = '<a style="font-weight:bold" href="' . $linked_object->getObjectUrl() . '"> <span style="padding: 1px 0 3px 18px;" class="db-ico ico-unknown ico-' . $linked_object->getObjectTypeName() . $icon_class . '"/>' . clean($linked_object->getObjectName()) . '</a>';
} else {
$linked_object_link = '';
}
if ($object) {
return lang('activity ' . $this->getAction(), lang('the ' . $object->getObjectTypeName()), $user->getDisplayName(), $object_link, $linked_object instanceof ApplicationDataObject ? lang('the ' . $linked_object->getObjectTypeName()) : '', $linked_object_link);
} else {
return lang('activity ' . $this->getAction(), lang('the ' . $this->getRelObjectManager()), $user->getDisplayName(), $object_link);
}
case ApplicationLogs::ACTION_LOGIN:
case ApplicationLogs::ACTION_LOGOUT:
return lang('activity ' . $this->getAction(), $user->getDisplayName());
case ApplicationLogs::ACTION_MOVE:
$exploded = explode(";", $this->getLogData());
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:ApplicationLog.class.php
示例20: getObjectLogs
/**
* Return entries related to specific object
*
* If $include_private is set to true private entries will be included in result. If $include_silent is set to true
* logs marked as silent will also be included. $limit and $offset are there to control the range of the result,
* usually we don't want to pull the entire log but just the few most recent entries. If NULL they will be ignored
*
* @param ApplicationDataObject $object
* @param boolean $include_private
* @param boolean $include_silent
* @param integer $limit
* @param integer $offset
* @return array
*/
static function getObjectLogs($object, $include_private = false, $include_silent = false, $limit = null, $offset = null)
{
$private_filter = $include_private ? 1 : 0;
$silent_filter = $include_silent ? 1 : 0;
if (get_class($object->manager()) == 'Users') {
$private_filter = $include_private ? 1 : 0;
$silent_filter = $include_silent ? 1 : 0;
$userCond = " AND `taken_by_id` = " . $object->getId();
if (isset($project_ids) && $project_ids != null) {
$conditions = array('`is_private` <= ? AND `is_silent` <= ? AND ' . self::getWorkspaceString($project_ids) . $userCond, $private_filter, $silent_filter);
} else {
$conditions
|
请发表评论