/** * Add a task to users own favorite list */ public function add($taskId) { global $USER; $result = array(); if ($taskId = $this->checkTaskId($taskId)) { // user can add a task ONLY to his OWN favorite-list $task = new \CTaskItem($taskId, $USER->GetId()); $task->addToFavorite(); } return $result; }
/** * See CSocNetLogFavorites::Add() and CSocNetLogFavorites::Change() */ public static function OnSonetLogFavorites(array $params) { $params['USER_ID'] = intval($params['USER_ID']); $params['LOG_ID'] = intval($params['LOG_ID']); if ($params['USER_ID'] && $params['LOG_ID'] && static::includeModule()) { $res = \CSocNetLog::GetById($params['LOG_ID']); if (!empty($res)) { $taskId = intval($res['SOURCE_ID']); try { $task = new \CTaskItem($taskId, $params['USER_ID']); // ensure task exists if ($params['OPERATION'] == 'ADD') { $task->addToFavorite(array('TELL_SOCNET' => false)); } else { $task->deleteFromFavorite(array('TELL_SOCNET' => false)); } } catch (\TasksException $e) { return; } } } }