本文整理汇总了PHP中Tags::addObjectTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::addObjectTag方法的具体用法?PHP Tags::addObjectTag怎么用?PHP Tags::addObjectTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::addObjectTag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_tag_file
function do_tag_file($tag, $ids)
{
$err = $succ = 0;
foreach ($ids as $id) {
if (trim($id) != '') {
try {
$file = ProjectFiles::findById($id);
if (!$file->canEdit(logged_user())) {
$err++;
} else {
Tags::addObjectTag($tag, $file);
ApplicationLogs::createLog($file, $file->getWorkspaces(), ApplicationLogs::ACTION_TAG, false, null, true, $tag);
$succ++;
}
} catch (Exception $e) {
$err++;
}
}
}
return array($succ, $err);
}
示例2: resolveAction
/**
* Resolve action to perform
*
* @param string $action
* @param array $attributes
* @return string $message
*/
private function resolveAction($action, $attributes)
{
$resultMessage = "";
$resultCode = 0;
switch ($action) {
case "delete":
$err = 0;
$succ = 0;
for ($i = 0; $i < count($attributes["ids"]); $i++) {
$id = $attributes["ids"][$i];
$type = $attributes["types"][$i];
switch ($type) {
case "email":
$email = MailContents::findById($id);
if (isset($email) && $email->canDelete(logged_user())) {
if ($email->getState() == 2) {
// we are deleting a draft email
$emails_in_conversation = array($email);
} else {
if (user_config_option('show_emails_as_conversations', true, logged_user()->getId())) {
$emails_in_conversation = MailContents::getMailsFromConversation($email);
} else {
$emails_in_conversation = array($email);
}
}
foreach ($emails_in_conversation as $email) {
if ($email->canDelete(logged_user())) {
try {
$email->trash();
ApplicationLogs::createLog($email, $email->getWorkspaces(), ApplicationLogs::ACTION_TRASH);
$succ++;
} catch (Exception $e) {
$err++;
}
} else {
$err++;
}
}
} else {
$err++;
}
break;
default:
$err++;
break;
}
// switch
}
// for
if ($err > 0) {
$resultCode = 2;
$resultMessage = lang("error delete objects", $err) . "<br />" . ($succ > 0 ? lang("success delete objects", $succ) : "");
} else {
$resultMessage = lang("success delete objects", $succ);
}
ajx_add("overview-panel", "reload");
break;
case "tag":
$tag = $attributes["tag"];
if (!trim($tag)) {
break;
}
for ($i = 0; $i < count($attributes["ids"]); $i++) {
$id = $attributes["ids"][$i];
$type = $attributes["types"][$i];
switch ($type) {
case "email":
$email = MailContents::findById($id);
if (isset($email)) {
if (user_config_option('show_emails_as_conversations', true, logged_user()->getId())) {
$emails_in_conversation = MailContents::getMailsFromConversation($email);
} else {
$emails_in_conversation = array($email);
}
foreach ($emails_in_conversation as $email) {
if ($email->canEdit(logged_user())) {
Tags::addObjectTag($tag, $email);
ApplicationLogs::createLog($email, $email->getWorkspaces(), ApplicationLogs::ACTION_TAG, false, null, true, $tag);
}
}
$resultMessage = lang("success tag objects", '');
}
break;
default:
$resultMessage = lang("Unimplemented type: '" . $type . "'");
// if
$resultCode = 2;
break;
}
// switch
}
// for
break;
//.........这里部分代码省略.........
示例3: resolveAction
//.........这里部分代码省略.........
$type = $attributes["types"][$i];
switch ($type) {
case "message":
$message = ProjectMessages::findById($id);
try {
$message->setIsRead(logged_user()->getId(), false);
$succ++;
} catch (Exception $e) {
$err++;
}
// try
break;
default:
$err++;
break;
}
// switch
}
// for
if ($err > 0) {
$resultCode = 2;
$resultMessage = lang("error markasunread objects", $err) . "<br />" . ($succ > 0 ? lang("success markasunread objects", $succ) : "");
}
break;
case "tag":
$tag = $attributes["tag"];
for ($i = 0; $i < count($attributes["ids"]); $i++) {
$id = $attributes["ids"][$i];
$type = $attributes["types"][$i];
switch ($type) {
case "message":
$message = ProjectMessages::findById($id);
if (isset($message) && $message->canEdit(logged_user())) {
Tags::addObjectTag($tag, $message);
ApplicationLogs::createLog($message, $message->getWorkspaces(), ApplicationLogs::ACTION_TAG, false, null, true, $tag);
$resultMessage = lang("success tag objects", '');
}
break;
default:
$resultMessage = lang("Unimplemented type: '" . $type . "'");
// if
$resultCode = 2;
break;
}
// switch
}
// for
break;
case "untag":
$tag = $attributes["tag"];
for ($i = 0; $i < count($attributes["ids"]); $i++) {
$id = $attributes["ids"][$i];
$type = $attributes["types"][$i];
switch ($type) {
case "message":
$message = ProjectMessages::findById($id);
if (isset($message) && $message->canEdit(logged_user())) {
if ($tag != '') {
$message->deleteTag($tag);
} else {
$message->clearTags();
}
$resultMessage = lang("success untag objects", '');
}
break;
default:
示例4: multi_task_action
function multi_task_action()
{
ajx_current("empty");
$ids = explode(',', array_var($_POST, 'ids'));
$action = array_var($_POST, 'action');
$options = array_var($_POST, 'options');
if (!is_array($ids) || trim(array_var($_POST, 'ids')) == '' || count($ids) <= 0) {
flash_error(lang('no items selected'));
return;
}
$tasks = ProjectTasks::findAll(array('conditions' => 'id in (' . implode(',', $ids) . ')'));
$tasksToReturn = array();
$showSuccessMessage = true;
try {
DB::beginWork();
foreach ($tasks as $k => $task) {
switch ($action) {
case 'tag':
if ($task->canEdit(logged_user())) {
$tag = $options;
Tags::addObjectTag($tag, $task);
ApplicationLogs::createLog($task, $task->getWorkspaces(), ApplicationLogs::ACTION_TAG, false, null, true, $tag);
$tasksToReturn[] = $task->getArrayInfo();
}
break;
case 'untag':
if ($task->canEdit(logged_user())) {
$tag = $options;
if ($tag != '') {
$task->deleteTag($tag);
} else {
$task->clearTags();
}
//ApplicationLogs::createLog($task, $task->getWorkspaces(), ApplicationLogs::ACTION_TAG,false,null,true,$tag);
$tasksToReturn[] = $task->getArrayInfo();
}
break;
case 'complete':
if ($task->canEdit(logged_user())) {
$task->completeTask();
$tasksToReturn[] = $task->getArrayInfo();
}
break;
case 'delete':
if ($task->canDelete(logged_user())) {
$tasksToReturn[] = array('id' => $task->getId());
$subtasks = $task->getAllSubtasks();
$task->trash();
ApplicationLogs::createLog($task, $task->getWorkspaces(), ApplicationLogs::ACTION_TRASH);
foreach ($subtasks as $st) {
ApplicationLogs::createLog($st, $st->getWorkspaces(), ApplicationLogs::ACTION_TRASH);
}
}
break;
case 'archive':
if ($task->canEdit(logged_user())) {
$tasksToReturn[] = $task->getArrayInfo();
$subtasks = $task->getAllSubtasks();
$task->archive();
ApplicationLogs::createLog($task, $task->getWorkspaces(), ApplicationLogs::ACTION_ARCHIVE);
foreach ($subtasks as $st) {
ApplicationLogs::createLog($st, $st->getWorkspaces(), ApplicationLogs::ACTION_ARCHIVE);
}
}
break;
case 'start_work':
if ($task->canEdit(logged_user())) {
$task->addTimeslot(logged_user());
ApplicationLogs::createLog($task, $task->getWorkspaces(), ApplicationLogs::ACTION_EDIT);
$tasksToReturn[] = $task->getArrayInfo();
$showSuccessMessage = false;
}
break;
case 'close_work':
if ($task->canEdit(logged_user())) {
$task->closeTimeslots(logged_user(), array_var($_POST, 'options'));
ApplicationLogs::createLog($task, $task->getWorkspaces(), ApplicationLogs::ACTION_EDIT);
$tasksToReturn[] = $task->getArrayInfo();
$showSuccessMessage = false;
}
break;
case 'pause_work':
if ($task->canEdit(logged_user())) {
$task->pauseTimeslots(logged_user());
$tasksToReturn[] = $task->getArrayInfo();
$showSuccessMessage = false;
}
break;
case 'resume_work':
if ($task->canEdit(logged_user())) {
$task->resumeTimeslots(logged_user());
$tasksToReturn[] = $task->getArrayInfo();
$showSuccessMessage = false;
}
break;
case 'markasread':
$task->setIsRead(logged_user()->getId(), true);
$tasksToReturn[] = $task->getArrayInfo();
$showSuccessMessage = false;
break;
//.........这里部分代码省略.........
示例5: do_tag_object
function do_tag_object($tag, $ids, $manager = null)
{
$err = $succ = 0;
foreach ($ids as $id) {
if (trim($id) != '') {
try {
if ($manager) {
$obj = get_object_by_manager_and_id($id, $manager);
Tags::addObjectTag($tag, $obj, $obj->getProject());
} else {
//call from dashboard, format is manager:id
$split = explode(":", $id);
$obj = get_object_by_manager_and_id($split[1], $split[0]);
Tags::addObjectTag($tag, $obj, $obj->getProject());
}
if ($obj instanceof ProjectDataObject) {
if ($obj->isSearchable()) {
$obj->addTagsToSearchableObject();
}
ApplicationLogs::createLog($obj, $obj->getWorkspaces(), ApplicationLogs::ACTION_TAG, false, null, true, $tag);
}
$succ++;
} catch (Exception $e) {
$err++;
}
}
}
return array($succ, $err);
}