private function addRelation() { if ($this->registry->getObject('authenticate')->isLoggedIn() == true) { $subs = new Subscriptions($this->registry); $types = $subs->getType(true); $this->registry->getObject('template')->addTemplateBit('form_relationship', 'templates/form_relationship.php'); //echo $types; $this->registry->getObject('template')->getPage()->addPPTag('relationship_types', array('SQL', $types)); } else { $this->registry->getObject('template')->getPage()->addPPTag('relationship_types', '<!-- relationship types dropdown -->'); } }
function output($mode) { global $application; loadCoreFile('html_form.php'); $this->_prefix = _ml_strtolower($mode); $this->_Prefix = _ml_strtoupper($mode[0]) . _ml_substr($this->_prefix, 1); $this->_PREFIX = _ml_strtoupper($mode); $this->_messageResources =& Subscriptions::getMessageResources(); $this->_tmplFiller = new TmplFiller(dirname(dirname(__FILE__)) . '/templates_az/'); $this->initFormData(); $result = ''; //$action = modApiFunc('Request', 'getValueByKey', 'asc_action'); $action = @$this->POST['asc_action']; $has_errors = sizeof($this->ErrorsArray) > 0; $stage = modApiFunc('Request', 'getValueByKey', 'stage'); if (empty($stage)) { $result = $this->outputAskEmails(); } elseif ($stage == 'confirm') { $result = $this->outputAskConfirmation(); } elseif ($stage == 'finish') { // @ show errors if were modApiFunc("application", "closeChild_UpdateParent"); } return $result; }
public function pushNotifications() { $notifications = $this->notifications->all(); foreach ($notifications as $notification) { $subscriptionId = $notification['subscription_id']; $subscriber = $this->subscriptions->getById($subscriptionId); if (is_null($subscriber)) { $this->log("Unknown subscriber: {$subscriptionId}"); $this->subscriptions->deleteById($subscriptionId); $this->notifications->deleteById($notification['id']); continue; } $notData = array_merge($notification, $subscriber, array('notificationId' => $notification['id'])); if ($this->push($notData)) { $this->notifications->deleteById($notification['id']); } else { $notification_json = json_encode($notData); $this->log("Pushing notification failed: {$notification_json}"); } } }
public function actionSubscript() { if (isset($_POST['ajax']) && $_POST['ajax'] === 'subscription-form') { echo CActiveForm::validate($this->subscription_form); Yii::app()->end(); } if (isset($_POST['SubscriptionForm'])) { $this->subscription_form->attributes = $_POST['SubscriptionForm']; if ($this->subscription_form->validate()) { $s = Subscriptions::model()->findByAttributes(array('email' => $this->subscription_form->email)); if ($s) { // message, already in list $this->redirect(array('site/index')); } else { $s = new Subscriptions(); $s->email = $this->subscription_form->email; $s->save(); $this->redirect(array('site/index')); // message, success } } } }
function output() { global $application; $this->_messageResources =& Subscriptions::getMessageResources(); $this->_tmplFiller = new TmplFiller(dirname(dirname(__FILE__)) . '/templates_az/'); $this->initFormData(); $this->fetchTopics(); if ($this->ViewState["hasCloseScript"] == "true") { modApiFunc("application", "closeChild_UpdateParent"); return; } $application->registerAttributes(array('TopicsList', 'TopicsIdsStr')); $vars = array('FormAction' => $this->urlSaveOrder()); $retval = $this->_tmplFiller->fill('', 'sort_topics.tpl.html', $vars); return $retval; }
/** * Handle on_project_object_moved event * * @param ProjectObject $object * @param Project $source * @param Project $destination * @return null */ function resources_handle_on_project_object_moved(&$object, &$source, &$destination) { if ($object->can_have_subscribers) { $subscribers = $object->getSubscribers(); if (is_foreachable($subscribers)) { foreach ($subscribers as $subscriber) { if (!$subscriber->isProjectMember($destination)) { Subscriptions::unsubscribe($subscriber, $object); } // if } // foreach } // if } // if $object_ids = array(); // Relations with milestones are carried out via milestone_id field if (instance_of($object, 'Milestone')) { db_execute('UPDATE ' . TABLE_PREFIX . 'project_objects SET milestone_id = 0 WHERE milestone_id = ?', $object->getId()); } // if $rows = db_execute_all('SELECT id FROM ' . TABLE_PREFIX . 'project_objects WHERE type IN (?) AND parent_id = ?', array('task', 'comment', 'attachment', 'timerecord'), $object->getId()); if (is_foreachable($rows)) { foreach ($rows as $row) { $object_ids[] = (int) $row['id']; } // foreach // Sub-objects (attachments for comments, time records for tasks, tasks for tickets) $rows = db_execute_all('SELECT id FROM ' . TABLE_PREFIX . 'project_objects WHERE parent_id IN (?)', $object_ids); if (is_foreachable($rows)) { foreach ($rows as $row) { $object_ids[] = (int) $row['id']; } // foreach } // if // Update objects and activity logs db_execute('UPDATE ' . TABLE_PREFIX . 'project_objects SET project_id = ? WHERE id IN (?)', $destination->getId(), $object_ids); db_execute('UPDATE ' . TABLE_PREFIX . 'activity_logs SET project_id = ? WHERE object_id IN (?)', $destination->getId(), $object_ids); // Clear cache cache_remove_by_pattern(TABLE_PREFIX . 'activity_logs_id_*'); cache_remove_by_pattern(TABLE_PREFIX . 'project_objects_id_*'); } // if }
function output() { global $application; $this->_messageResources =& Subscriptions::getMessageResources(); $this->_tmplFiller = new TmplFiller(dirname(dirname(__FILE__)) . '/templates_az/'); $this->initFormData(); if ($this->ViewState['hasCloseScript'] == 'true') { modApiFunc('application', 'closeChild'); return; } $config_array = LayoutConfigurationManager::static_get_cz_layouts_list(); $config = reset($config_array); $url = $config['SITE_URL'] . 'unsubscribe.php?key=%KEY_UNSUBSCRIBE%'; $signature = modApiFunc('Configuration', 'getValue', SYSCONFIG_NEWSLETTERS_SIGNATURE); $vars = array('FormAction' => $this->urlSaveSignature(), 'SignatureHtml' => htmlspecialchars($signature), 'TipUnsubscribe' => getMsg('SUBSCR', 'TIP_SIGNATURE', $url)); $retval = $this->_tmplFiller->fill('', 'signature.tpl.html', $vars); return $retval; }
function output() { global $application; loadCoreFile('html_form.php'); $this->_messageResources =& Subscriptions::getMessageResources(); $this->_tmplFiller = new TmplFiller(dirname(dirname(__FILE__)) . '/templates_az/'); $this->_topics_ids = modApiFunc('Request', 'getValueByKey', 'topics'); $this->initFormData(); if (@$this->ViewState['hasCloseScript'] == 'true') { modApiFunc("application", "closeChild_UpdateParent"); return; } $this->_templateContents = array('ErrorsBox', 'TopicsList'); $application->registerAttributes($this->_templateContents); $vars = array('FormAction' => $this->urlSelf(), 'TopicsIds' => $this->_topics_ids); $result = $this->_tmplFiller->fill('delete_topics/', 'delete_topics.tpl.html', $vars); return $result; }
/** * Render object subscriptions icon and link * * Params: * * - object - Object user needs to be subscribed to * - user - User who is subscribed, if not set logged user is used * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_subscription($params, &$smarty) { $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('$object', $object, '$object is expected to be a valid instance of ProjectObject class', true); } // if $user = array_var($params, 'user'); if (!instance_of($user, 'User')) { return new InvalidParamError('$user', $user, '$user is expected to be a valid instance of User class', true); } // if $render_wrapper = (bool) array_var($params, 'render_wrapper', true); $wrapper_id = 'object_subscription_widget_' . $object->getId() . '_user_' . $user->getId(); require_once SMARTY_PATH . '/plugins/block.link.php'; if (Subscriptions::isSubscribed($user, $object)) { $content = '<a href="' . $object->getUnsubscribeUrl($user) . '" title="' . lang('Click to unsubscribe') . '"><img src="' . get_image_url('subscribe-small.gif') . '" alt="" /></a>'; } else { $content = '<a href="' . $object->getSubscribeUrl($user) . '" title="' . lang('Click to subscribe') . '"><img src="' . get_image_url('gray-subscribe-small.gif') . '" alt="" /></a>'; } // if $content .= '<script type="text/javascript">App.layout.init_subscribe_unsubscribe_link("' . $wrapper_id . '")</script>'; return $render_wrapper ? '<span id="' . $wrapper_id . '">' . $content . '</span>' : $content; }
/** * Delete this object * * If $drop_subitems is TRUE subitems will be delete from the database. If it * is false relation will be nullified * * @param boolean $drop_subitems * @return boolean * @throws DBQueryError */ function delete($drop_subitems = true) { db_begin_work(); $delete = parent::delete(); if (is_error($delete) || !$delete) { db_rollback(); return $delete; } // if $subitems = $this->getSubitems(); if (is_foreachable($subitems)) { foreach ($subitems as $subitem) { if ($drop_subitems) { $delete = $subitem->delete(); if (is_error($delete)) { db_rollback(); return $delete; } // if } else { $subitem->setParent(null, false); $save = $subitem->save(); if (is_error($save)) { db_rollback(); return $save; } // if } // if } // foreach } // if StarredObjects::deleteByObject($this); // Attachments if ($this->can_have_attachments) { Attachments::deleteByObject($this); } // if // Subscriptions if ($this->can_have_subscribers) { Subscriptions::deleteByParent($this); } // if // Asignments if ($this->can_have_assignees) { Assignments::deleteByObject($this); } // if // Activity log if ($this->log_activities) { ActivityLogs::deleteByObject($this); } // if // Reminders if ($this->can_send_reminders) { Reminders::deleteByObject($this); } // if search_index_remove($this->getId(), 'ProjectObject'); db_commit(); return true; }
} */ $Cache->cache_value('notifications_new_' . $LoggedUser['ID'], $NewNotifications, 0); } } // News $MyNews = $LoggedUser['LastReadNews']; $CurrentNews = $Cache->get_value('news_latest_id'); if ($CurrentNews === false) { $DB->query("\n\t\tSELECT ID\n\t\tFROM news\n\t\tORDER BY Time DESC\n\t\tLIMIT 1"); if ($DB->record_count() === 1) { list($CurrentNews) = $DB->next_record(); } else { $CurrentNews = -1; } $Cache->cache_value('news_latest_id', $CurrentNews, 0); } // Blog $MyBlog = $LoggedUser['LastReadBlog']; $CurrentBlog = $Cache->get_value('blog_latest_id'); if ($CurrentBlog === false) { $DB->query("\n\t\tSELECT ID\n\t\tFROM blog\n\t\tWHERE Important = 1\n\t\tORDER BY Time DESC\n\t\tLIMIT 1"); if ($DB->record_count() === 1) { list($CurrentBlog) = $DB->next_record(); } else { $CurrentBlog = -1; } $Cache->cache_value('blog_latest_id', $CurrentBlog, 0); } // Subscriptions $NewSubscriptions = Subscriptions::has_new_subscriptions(); json_die("success", array('username' => $LoggedUser['Username'], 'id' => (int) $LoggedUser['ID'], 'authkey' => $LoggedUser['AuthKey'], 'passkey' => $LoggedUser['torrent_pass'], 'notifications' => array('messages' => (int) $NewMessages, 'notifications' => (int) $NewNotifications, 'newAnnouncement' => $MyNews < $CurrentNews, 'newBlog' => $MyBlog < $CurrentBlog, 'newSubscriptions' => $NewSubscriptions == 1), 'userstats' => array('uploaded' => (int) $LoggedUser['BytesUploaded'], 'downloaded' => (int) $LoggedUser['BytesDownloaded'], 'ratio' => (double) $Ratio, 'requiredratio' => (double) $LoggedUser['RequiredRatio'], 'class' => $ClassLevels[$LoggedUser['Class']]['Name'])));
//Merge it } else { $Forum = $Part1 + $Part2 + $Part3; //Merge it } $Cache->cache_value("forums_{$ForumID}", array($Forum, '', 0, $Stickies), 0); //Update the forum root $Cache->begin_transaction('forums_list'); $Cache->update_row($ForumID, array('NumPosts' => '+1', 'LastPostID' => $PostID, 'LastPostAuthorID' => $LoggedUser['ID'], 'LastPostTopicID' => $TopicID, 'LastPostTime' => $SQLTime, 'Title' => $ThreadInfo['Title'], 'IsLocked' => $ThreadInfo['IsLocked'], 'IsSticky' => $ThreadInfo['IsSticky'])); $Cache->commit_transaction(0); } else { //If there's no cache, we have no data, and if there's no data $Cache->delete_value('forums_list'); } //This calculates the block of 500 posts that this one will fall under $CatalogueID = floor((POSTS_PER_PAGE * ceil($ThreadInfo['Posts'] / POSTS_PER_PAGE) - POSTS_PER_PAGE) / THREAD_CATALOGUE); //Insert the post into the thread catalogue (block of 500 posts) $Cache->begin_transaction("thread_{$TopicID}" . "_catalogue_{$CatalogueID}"); $Cache->insert('', array('ID' => $PostID, 'AuthorID' => $LoggedUser['ID'], 'AddedTime' => $SQLTime, 'Body' => $Body, 'EditedUserID' => 0, 'EditedTime' => '0000-00-00 00:00:00', 'Username' => $LoggedUser['Username'])); $Cache->commit_transaction(0); //Update the thread info $Cache->begin_transaction("thread_{$TopicID}" . '_info'); $Cache->update_row(false, array('Posts' => '+1', 'LastPostAuthorID' => $LoggedUser['ID'])); $Cache->commit_transaction(0); //Increment this now to make sure we redirect to the correct page $ThreadInfo['Posts']++; } Subscriptions::flush_subscriptions('forums', $TopicID); Subscriptions::quote_notify($Body, $PostID, 'forums', $TopicID); header("Location: forums.php?action=viewthread&threadid={$TopicID}&page=" . ceil($ThreadInfo['Posts'] / $PerPage)); die;
echo $CollageID; ?> "><?php echo $Name; ?> </a> </h2> <div class="linkbox"> <a href="#" id="subscribelink_collages<?php echo $CollageID; ?> " class="brackets" onclick="SubscribeComments('collages', <?php echo $CollageID; ?> ); return false;"><?php echo Subscriptions::has_subscribed_comments('collages', $CollageID) !== false ? 'Unsubscribe' : 'Subscribe'; ?> </a> <?php $Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9); if ($Pages) { echo '<br /><br />' . $Pages; } ?> </div> </div> <?php //---------- Begin printing CommentsView::render_comments($Thread, $LastRead, "collages.php?action=comments&collageid={$CollageID}"); if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) { if ($ThreadInfo['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) {
function onOrderCreated($order_id) { $email = modApiFunc('Checkout', 'getCustomerAttributeValue', $order_id, 'billinginfo', 'default', 'Email'); if (!modApiFunc('Users', 'isValidEmail', $email)) { return; } Subscriptions::setCustomerSubscribedEmail($email); $mode = modApiFunc('Settings', 'getParamValue', 'SUBSCRIPTIONS', 'CHECKOUT_SUBSCRIBE_MODE'); if ($mode == 'AUTO') { $signed_id = modApiFunc('Customer_Account', 'getCurrentSignedCustomer') !== null; $access = array(SUBSCRIPTION_TOPIC_FULL_ACCESS, $signed_id ? SUBSCRIPTION_TOPIC_REGISTERED_ONLY : SUBSCRIPTION_TOPIC_GUEST_ONLY); $topics_ids = execQuery('SUBSCR_GET_AUTO_SUBSCRIBE_TOPICS', array('access' => $access)); if (!empty($topics_ids)) { foreach (array_keys($topics_ids) as $i) { $topics_ids[$i] = $topics_ids[$i]['topic_id']; } Subscriptions::subscribeEmails($topics_ids, $email); } } elseif ($mode == 'MANUAL') { $prerequisiteValidationResults = modApiFunc('Checkout', 'getPrerequisiteValidationResults', 'subscriptionTopics'); $ids = @$prerequisiteValidationResults['validatedData']['Topics']['value']; $topics_ids = empty($ids) ? array() : explode(',', $ids); if (!empty($topics_ids)) { Subscriptions::subscribeEmails($topics_ids, $email); } } $order = execQuery('SELECT_BASE_ORDER_INFO', array('order_id' => $order_id)); if (!empty($order)) { $params = array('customer_id' => $order[0]['person_id'], 'email' => $email); execQuery('SUBSCR_LINK_SUBSCRIPTION_TO_CUSTOMER', $params); } }
/** * Unsubscribe specific user from a given object * * @param void * @return null */ function unsubscribe_user() { if (!$this->active_object->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_NOT_FOUND, null, true, $this->request->isApiCall()); } // if if ($this->request->isSubmitted()) { $user = null; $user_id = (int) $this->request->get('user_id'); if ($user_id) { $user = Users::findById($user_id); } // if if (!instance_of($user, 'User')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $subscription = Subscriptions::findById(array('user_id' => $user->getId(), 'parent_id' => $this->active_object->getId())); if (!instance_of($subscription, 'Subscription')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $delete = $subscription->delete(); if ($delete && !is_error($delete)) { flash_success(':user_name has been unsubscribed from :object_name :object_type', array('user_name' => $user->getDisplayName(), 'object_name' => $this->active_object->getName(), 'object_type' => $this->active_object->getVerboseType(true))); } else { flash_error('Failed to unsubscribe :user_name from :object_name :object_type', array('user_name' => $user->getDisplayName(), 'object_name' => $this->active_object->getName(), 'object_type' => $this->active_object->getVerboseType(true))); } // if $this->redirectToReferer($this->active_object->getSubscriptionsUrl()); } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if }
?> " onclick="Bookmark('request', <?php echo $RequestID; ?> , 'Remove bookmark'); return false;" class="brackets">Bookmark</a> <?php } ?> <a href="#" id="subscribelink_requests<?php echo $RequestID; ?> " class="brackets" onclick="SubscribeComments('requests',<?php echo $RequestID; ?> );return false;"><?php echo Subscriptions::has_subscribed_comments('requests', $RequestID) !== false ? 'Unsubscribe' : 'Subscribe'; ?> </a> <a href="reports.php?action=report&type=request&id=<?php echo $RequestID; ?> " class="brackets">Report request</a> <?php if (!$IsFilled) { ?> <a href="upload.php?requestid=<?php echo $RequestID; echo $Request['GroupID'] ? "&groupid={$Request['GroupID']}" : ''; ?> " class="brackets">Upload request</a> <?php
/** * Clean up system by object ID-s * * This function cleans up project objects recursively. It is also infinite * loop safe because it will filter out ID-s that are already removed * * @param array $ids * @return null */ function cleanUpByIds($ids) { static $cleaned_ids = array(); // Remove objects that are already cleaned if (is_foreachable($ids)) { foreach ($ids as $k => $id) { if (isset($cleaned_ids[$id]) && $cleaned_ids[$id]) { unset($ids[$k]); } else { $cleaned_ids[$id] = false; } // if } // foreach } // if if (is_foreachable($ids)) { db_begin_work(); Attachments::deleteByProjectObjectIds($ids); Subscriptions::deleteByObjectIds($ids); Assignments::deleteByObjectIds($ids); ActivityLogs::deleteByObjectIds($ids); StarredObjects::deleteByObjectIds($ids); Reminders::deleteByObjectIds($ids); search_index_remove($ids, 'ProjectObject'); $rows = db_execute_all('SELECT DISTINCT id FROM ' . TABLE_PREFIX . 'project_objects WHERE parent_id IN (?)', $ids); if (is_foreachable($rows)) { $subobject_ids = array(); foreach ($rows as $row) { $subobject_ids[] = (int) $row['id']; } // foreach ProjectObjects::cleanUpByIds($subobject_ids); } // if ProjectObjects::delete(array('id IN (?)', $ids)); foreach ($ids as $id) { $cleaned_ids[$id] = true; } // if db_commit(); } // if return true; }
/** * Show and process add task form * * @param void * @return null */ function add() { $this->wireframe->print_button = false; if (!instance_of($this->active_task_parent, 'ProjectObject')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_task_parent->canSubtask($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $task_data = $this->request->post('task'); $this->smarty->assign(array('task_data' => $task_data, 'page_tab' => $this->active_task_parent->getProjectTab())); if ($this->request->isSubmitted()) { db_begin_work(); $this->active_task = new Task(); // just in case... $this->active_task->log_activities = false; $this->active_task->setAttributes($task_data); $this->active_task->setParent($this->active_task_parent); $this->active_task->setProjectId($this->active_project->getId()); if (trim($this->active_task->getCreatedByName()) == '' || trim($this->active_task->getCreatedByEmail()) == '') { $this->active_task->setCreatedBy($this->logged_user); } // if $this->active_task->setState(STATE_VISIBLE); $this->active_task->setVisibility($this->active_task_parent->getVisibility()); $save = $this->active_task->save(); if ($save && !is_error($save)) { $subscribers = array($this->logged_user->getId()); if (is_foreachable(array_var($task_data['assignees'], 0))) { $subscribers = array_merge($subscribers, array_var($task_data['assignees'], 0)); } else { $subscribers[] = $this->active_project->getLeaderId(); } // if if (!in_array($this->active_project->getLeaderId(), $subscribers)) { $subscribers[] = $this->active_project->getLeaderId(); } // if Subscriptions::subscribeUsers($subscribers, $this->active_task); $activity = new NewTaskActivityLog(); $activity->log($this->active_task, $this->logged_user); db_commit(); $this->active_task->ready(); //BOF:mod $recurring_flag = $task_data['recurring_flag']; $recurring_period = $task_data['recurring_period']; $recurring_period_type = $task_data['recurring_period_type']; $recurring_period_condition = $task_data['recurring_period_condition']; //$recurring_end_date = str_replace('/', '-', $task_data['recurring_end_date']); /// $reminder = str_replace('/', '-', $task_data['reminder']); $recurring_end_date = dateval($task_data['recurring_end_date']); /*$reminder = dateval($task_data['reminder']); $reminderhours = (int)$task_data['reminderhours']; $reminderminutes = (int)$task_data['reminderminutes']; $remindermeridian = $task_data['remindermeridian']; if (!empty($reminder)){ if (!empty($remindermeridian) && $remindermeridian=='PM' && $reminderhours<12){ $reminderhours += 12; } elseif (!empty($remindermeridian) && $remindermeridian=='AM' && $reminderhours==12){ $reminderhours = 0; } $reminder = $reminder . ' ' . $reminderhours . ':' . $reminderminutes; }*/ $email_flag = empty($task_data['email_flag']) ? '0' : '1'; if ($email_flag == '1') { $email_reminder_period = (int) $task_data['figure_before_due_date']; $email_reminder_unit = empty($task_data['unit_before_due_date']) ? 'D' : $task_data['unit_before_due_date']; $email_reminder_hours = empty($task_data['reminderhours']) ? '6' : $task_data['reminderhours']; $email_reminder_minutes = (int) $task_data['reminderminutes']; $email_reminder_meridian = empty($task_data['remindermeridian']) ? 'AM' : $task_data['remindermeridian']; $email_reminder_time = ''; if ($email_reminder_meridian == 'PM' && $email_reminder_hours < 12) { $email_reminder_time = $email_reminder_hours + 12 . ':'; } elseif ($email_reminder_meridian == 'AM' && $email_reminder_hours == 12) { $email_reminder_time = '00:'; } else { $email_reminder_time = str_pad($email_reminder_hours, 2, '0', STR_PAD_LEFT) . ':'; } $email_reminder_time .= $email_reminder_minutes; } $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); //if (empty($recurring_flag) && empty($reminder) && empty($email_flag)){ if (empty($recurring_flag) && empty($email_flag)) { $query = "delete from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'"; mysql_query($query, $link); } else { if (empty($recurring_flag)) { $recurring_period = ''; $recurring_period_type = ''; $recurring_period_condition = ''; $recurring_end_date = ''; } else { if (empty($recurring_period) || (int) $recurring_period == 0) { $recurring_period = '7'; } } $query = "select * from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'"; $result = mysql_query($query, $link); if (mysql_num_rows($result)) { $query01 = "update healingcrystals_project_object_misc set\n recurring_period='" . $recurring_period . "',\n recurring_period_type='" . $recurring_period_type . "',\n recurring_period_condition='" . $recurring_period_condition . "',\n recurring_end_date='" . $recurring_end_date . "', " . "auto_email_status='" . $email_flag . "',\n\t\t\t\t\t\t\t\t\temail_reminder_period=" . ($email_flag == '1' ? "'" . $email_reminder_period . "'" : "null") . ", \n\t\t\t\t\t\t\t\t\temail_reminder_unit=" . ($email_flag == '1' ? "'" . $email_reminder_unit . "'" : "null") . ", \n\t\t\t\t\t\t\t\t\temail_reminder_time=" . ($email_flag == '1' ? "'" . $email_reminder_time . "'" : "null") . ", \n last_modified=now() where object_id='" . $this->active_task->getId() . "'"; mysql_query($query01, $link); } else { $query01 = "insert into healingcrystals_project_object_misc\n (object_id, " . "recurring_period,\n recurring_period_type,\n recurring_period_condition,\n recurring_end_date,\n date_added,\n auto_email_status, \n\t\t\t\t\t\t\t\t\t email_reminder_period, \n\t\t\t\t\t\t\t\t\t email_reminder_unit, \n\t\t\t\t\t\t\t\t\t email_reminder_time) values\n ('" . $this->active_task->getId() . "', " . "'" . $recurring_period . "',\n '" . $recurring_period_type . "',\n '" . $recurring_period_condition . "',\n '" . $recurring_end_date . "',\n now(),\n '" . $email_flag . "', \n\t\t\t\t\t\t\t\t\t " . ($email_flag == '1' ? "'" . $email_reminder_period . "'" : "null") . ", \n\t\t\t\t\t\t\t\t\t " . ($email_flag == '1' ? "'" . $email_reminder_unit . "'" : "null") . ", \n\t\t\t\t\t\t\t\t\t " . ($email_flag == '1' ? "'" . $email_reminder_time . "'" : "null") . ")"; mysql_query($query01, $link); } } mysql_close($link); //EOF:mod if ($this->request->isApiCall()) { $this->serveData($this->active_task, 'task'); } elseif ($this->request->isAsyncCall()) { $this->smarty->assign(array('_object_task' => $this->active_task)); print tpl_fetch(get_template_path('_task_opened_row', $this->controller_name, RESOURCES_MODULE)); die; } else { //flash_success('Task ":name" has been added', array('name' => str_excerpt($this->active_task->getBody(), 80, '...')), false, false); //bof:mod flash_success('Task ":name" has been added', array('name' => str_excerpt(strip_tags($this->active_task->getBody()), 80, '...')), false, false); //eof:mod $this->redirectToUrl($this->active_task_parent->getViewUrl()); } // if } else { db_rollback(); if ($this->request->isApiCall() || $this->request->isAsyncCall()) { $this->serveData($save); } else { $this->smarty->assign('errors', $save); //$this->smarty->assign('add_content', ''); } // if } // if } else { if ($this->request->isApiCall()) { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if } // if }
if ($data['trap'] == '') { $subscribe = new Subscriptions($data['email'], $data['category_id'], $data['city_id']); if ($subscribe->createSubscription($subscription_for)) { $app->flash('success', "A subscription confirmation was sent to your email address."); } else { $app->flash('danger', "Your subscription failed. You may have an existing subscription already."); } $app->redirect(BASE_URL . "{$redirect}/{$id}"); } else { $app->flash('danger', "Your subscription failed. You are not allowed to subscriibe."); $app->redirect(BASE_URL . "{$redirect}/{$id}"); } }); $app->get('/:id/:action/:token', 'isBanned', function ($id, $action, $token) use($app) { $status = $action == 'confirm' ? ACTIVE : INACTIVE; $s = new Subscriptions(''); $user = $s->getUserSubscription($id, $token); if ($user) { $s->updateSubscription($id, $status); if ($status == ACTIVE) { $app->flash('success', 'Thank you for confirming your subscription.'); } else { $app->flash('success', 'Your subscription has been canceled.'); } $app->redirect(BASE_URL); } else { $app->flash('danger', 'Your subscription could not be confirmed.'); $app->redirect(BASE_URL); } }); });
function getTopicStatusSelect($select_name, $selected_status = null) { $statuses = Subscriptions::getTopicStatusesNames(); $options = array(); foreach ($statuses as $status => $status_name) { $options[] = array('value' => $status, 'contents' => $status_name); } return HtmlForm::genDropdownSingleChoice(array('select_name' => $select_name, 'values' => $options, 'selected_value' => $selected_status)); }
/** * Show and process edit page form. Also, handle all other page update * requests * * @param void * @return null */ function edit() { $this->wireframe->print_button = false; if ($this->active_page->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_page->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if //BOF:mod 20110615 $subscribers = $this->active_page->getSubscribers(); $notify_users = array(array(), null); foreach ($subscribers as $subscriber) { $notify_users[0][] = $subscriber->getId(); } $this->smarty->assign('notify_users', $notify_users); //EOF:mod 20110615 $page_data = $this->request->post('page'); if (!is_array($page_data)) { $page_data = array('name' => $this->active_page->getName(), 'body' => $this->active_page->getBody(), 'visibility' => $this->active_page->getVisibility(), 'parent_id' => $this->active_page->getParentId(), 'milestone_id' => $this->active_page->getMilestoneId(), 'tags' => $this->active_page->getTags()); } // if //BOF:mod 20110519 //$subscribers = $this->active_page->getSubscribers(); //$page_data['subscribers'] = $subscribers; //EOF:mod 20110519 //BOF:mod 20121116 $options = array(); $options[] = array('url' => 'javascript:convert_object_to_milestone(\'' . $this->active_page->getProjectId() . '\', \'' . $this->active_page->getId() . '\', \'' . $this->active_page->getType() . '\');', 'text' => 'Milestone'); $options[] = array('url' => 'javascript:convert_object_to_ticket(\'' . $this->active_page->getProjectId() . '\', \'' . $this->active_page->getId() . '\', \'' . $this->active_page->getType() . '\');', 'text' => 'Ticket'); $this->wireframe->addPageAction(lang('Convert To'), 'javascript://', $options); //EOF:mod 20121116 $this->smarty->assign(array('page_data' => $page_data)); if ($this->request->isSubmitted()) { db_begin_work(); $old_page_name = $this->active_page->getName(); $old_page_body = $this->active_page->getBody(); $this->active_page->setAttributes($page_data); $new_version = null; $error = null; // Create a new version if (!array_var($page_data, 'is_minor_revision', false) && ($this->active_page->getName() != $old_page_name || $this->active_page->getBody() != $old_page_body)) { $new_version = $this->active_page->createVersion($this->logged_user); if (is_error($new_version)) { $error = $new_version; } // if } // if // Update page properties if we don't have an error already if (!is_error($error)) { //BOF:mod 20121122 if (!empty($page_data['new_team_id']) && $page_data['new_team_id'] != $this->active_project->getId()) { $this->active_page->setProjectId($page_data['new_team_id']); } //EOF:mod 20121122 $save = $this->active_page->save(); if (is_error($save)) { $error = $save; } // if } // if if (!is_error($error)) { if ($new_version) { //BOF:mod 20010519 /* //EOF:mod 20010519 event_trigger('on_new_revision', array(&$this->active_page, &$new_version, &$this->logged_user)); //BOF:mod 20010519 */ /*if ($page_data['subscribers_to_notify']){ $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); foreach($page_data['subscribers_to_notify'] as $fyi_user_id){ $query = "insert into healingcrystals_project_objects_to_fyi_users (fyi_user_id, selected_by_user_id, object_id) values ('" . $fyi_user_id . "', '" . $this->logged_user->getId() . "', '" . $this->active_page->getId() . "')"; mysql_query($query); } mysql_close($link); }*/ //EOF:mod 20010519 $activity_log = new NewPageVersionActivityLog(); $activity_log->log($this->active_page, $this->logged_user); } // if //BOF:mod 20110614 $subscribers = $this->request->post('notify_users'); if (!in_array($this->active_project->getLeaderId(), $subscribers)) { $subscribers[] = $this->active_project->getLeaderId(); } // if Subscriptions::subscribeUsers($subscribers, $this->active_page); //EOF:mod 20110614 //Subscriptions::subscribe($this->logged_user, $this->active_page); db_commit(); //BOF: mod $this->active_page->register_departments(!empty($page_data['departments']) ? $page_data['departments'] : array()); //EOF: mod //BOF:mod 20110614 $assignees_flag_data = $this->request->post('assignee'); $this->active_page->register_assignees_flag($assignees_flag_data); //EOF:mod 20110614 if ($this->request->getFormat() == FORMAT_HTML) { flash_success('Page ":name" has been updated', array('name' => $old_page_name)); $this->redirectToUrl($this->active_page->getViewUrl()); } else { $this->serveData($this->active_page, 'page'); } // if } else { db_rollback(); if ($this->request->getFormat() == FORMAT_HTML) { $this->smarty->assign('errors', $error); } else { $this->serveData($error); } // if } // if } // if }
/** * Delete from database * * @param void * @return boolean */ function delete() { db_begin_work(); $delete = parent::delete(); if ($delete && !is_error($delete)) { unlink($this->getAvatarPath()); unlink($this->getAvatarPath(true)); ProjectUsers::deleteByUser($this); Assignments::deleteByUser($this); Subscriptions::deleteByUser($this); StarredObjects::deleteByUser($this); PinnedProjects::deleteByUser($this); UserConfigOptions::deleteByUser($this); Reminders::deleteByUser($this); search_index_remove($this->getId(), 'User'); $cleanup = array(); event_trigger('on_user_cleanup', array(&$cleanup)); if (is_foreachable($cleanup)) { foreach ($cleanup as $table_name => $fields) { foreach ($fields as $field) { $condition = ''; if (is_array($field)) { $id_field = array_var($field, 'id'); $name_field = array_var($field, 'name'); $email_field = array_var($field, 'email'); $condition = array_var($field, 'condition'); } else { $id_field = $field . '_id'; $name_field = $field . '_name'; $email_field = $field . '_email'; } // if if ($condition) { db_execute('UPDATE ' . TABLE_PREFIX . "{$table_name} SET {$id_field} = 0, {$name_field} = ?, {$email_field} = ? WHERE {$id_field} = ? AND {$condition}", $this->getName(), $this->getEmail(), $this->getId()); } else { db_execute('UPDATE ' . TABLE_PREFIX . "{$table_name} SET {$id_field} = 0, {$name_field} = ?, {$email_field} = ? WHERE {$id_field} = ?", $this->getName(), $this->getEmail(), $this->getId()); } // if } // foreach } // foreach } // if db_commit(); return true; } else { db_rollback(); return $delete; } // if }
</div> <div class="preview_submit"> <?php if (isset($SubscribeBox) && !isset($ForumID) && Subscriptions::has_subscribed_comments($Document, $InputID) === false) { ?> <input id="subscribebox" type="checkbox" name="subscribe"<?php echo !empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''; ?> tabindex="2" /> <label for="subscribebox">Subscribe</label> <?php } // Forum thread logic // This might use some more abstraction if (isset($ForumID)) { if (!Subscriptions::has_subscribed($InputID)) { ?> <input id="subscribebox" type="checkbox" name="subscribe"<?php echo !empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''; ?> tabindex="2" /> <label for="subscribebox">Subscribe</label> <?php } if ($ThreadInfo['LastPostAuthorID'] == G::$LoggedUser['ID'] && (check_perms('site_forums_double_post') || in_array($ForumID, $ForumsDoublePost))) { ?> <input id="mergebox" type="checkbox" name="merge" tabindex="2" /> <label for="mergebox">Merge</label> <?php } if (!G::$LoggedUser['DisableAutoSave']) {
?> " class="add_bookmark brackets" onclick="Bookmark('torrent', <?php echo $GroupID; ?> , 'Remove bookmark'); return false;">Bookmark</a> <?php } ?> <a href="#" id="subscribelink_torrents<?php echo $GroupID; ?> " class="brackets" onclick="SubscribeComments('torrents', <?php echo $GroupID; ?> ); return false;"><?php echo Subscriptions::has_subscribed_comments('torrents', $GroupID) !== false ? 'Unsubscribe' : 'Subscribe'; ?> </a> <!-- <a href="#" id="recommend" class="brackets">Recommend</a> --> <?php if ($Categories[$GroupCategoryID - 1] == 'Music') { ?> <a href="upload.php?groupid=<?php echo $GroupID; ?> " class="brackets">Add format</a> <?php } if (check_perms('site_submit_requests')) { ?> <a href="requests.php?action=new&groupid=<?php
$title = $j->getSeoTitle(); $applications = $a->getApplications($start); $app->render(ADMIN_THEME . 'applications.job.php', array('applications' => $applications, 'number_of_pages' => $number_of_pages, 'current_page' => $page, 'page_name' => 'applications', 'count' => $count, 'title' => $title, 'id' => $id)); }); }); $app->group('/subscribers', function () use($app) { $app->get('(/(:page))', 'validateUser', function ($page = 1) use($app) { $s = new Subscriptions(''); $start = getPaginationStart($page); $count = $s->countSubscriptions(); $number_of_pages = ceil($count / LIMIT); $users = $s->getAllSubscriptions($start); $app->render(ADMIN_THEME . 'subscribers.php', array('users' => $users, 'number_of_pages' => $number_of_pages, 'current_page' => $page, 'count' => $count, 'page_name' => 'subscribers')); }); $app->get('/:id/:action/:token', 'validateUser', function ($id, $action, $token) use($app) { $s = new Subscriptions(''); $user = $s->getUserSubscription($id, $token); if (isset($user)) { switch ($action) { case 'approve': $s->updateSubscription($id, ACTIVE); $app->flash('success', 'User subscription is confirmed.'); break; case 'deactivate': $s->updateSubscription($id, INACTIVE); $app->flash('success', 'User subscription has been deactivated.'); break; case 'delete': $s->deleteSubscription($id, $token); $app->flash('success', 'User subscription has been deleted.'); break;
/** * Delete subscriptions by user * * @param User $user * @return boolean */ function deleteByUser($user) { return Subscriptions::delete(array('user_id = ?', $user->getId())); }
/** * Quick add milestone * * @param void * @return null */ function quick_add() { if (!Milestone::canAdd($this->logged_user, $this->active_project)) { $this->httpError(HTTP_ERR_FORBIDDEN, lang("You don't have permission for this action"), true, true); } // if $this->skip_layout = true; $milestone_data = $this->request->post('milestone'); if (!is_array($milestone_data)) { $milestone_data = array('visibility' => $this->active_project->getDefaultVisibility()); } // if $this->smarty->assign(array('milestone_data' => $milestone_data, 'quick_add_url' => assemble_url('project_milestones_quick_add', array('project_id' => $this->active_project->getId())))); if ($this->request->isSubmitted()) { db_begin_work(); $this->active_milestone = new Milestone(); $this->active_milestone->setAttributes($milestone_data); if (!isset($milestone_data['priority'])) { $this->active_milestone->setPriority(PRIORITY_NORMAL); } // if $this->active_milestone->setProjectId($this->active_project->getId()); $this->active_milestone->setCreatedBy($this->logged_user); $this->active_milestone->setState(STATE_VISIBLE); $this->active_milestone->setVisibility(VISIBILITY_NORMAL); $save = $this->active_milestone->save(); if ($save && !is_error($save)) { $subscribers = array($this->logged_user->getId()); if (is_foreachable(array_var($milestone_data['assignees'], 0))) { $subscribers = array_merge($subscribers, array_var($milestone_data['assignees'], 0)); } else { $subscribers[] = $this->active_project->getLeaderId(); } // if Subscriptions::subscribeUsers($subscribers, $this->active_milestone); db_commit(); $this->active_milestone->ready(); $this->smarty->assign(array('active_milestone' => $this->active_milestone, 'milestone_data' => array('visibility' => $this->active_project->getDefaultVisibility()), 'project_id' => $this->active_project->getId())); $this->skip_layout = true; } else { db_rollback(); $this->httpError(HTTP_ERR_OPERATION_FAILED, $save->getErrorsAsString(), true, true); } // if } // if }
/** * Upate discussion * * @param void * @return null */ function edit() { $this->wireframe->print_button = false; if ($this->request->isApiCall() && !$this->request->isSubmitted()) { $this->httpError(HTTP_ERR_BAD_REQUEST); } // ifs if ($this->active_discussion->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_discussion->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if //BOF:mod 20110615 $subscribers = $this->active_discussion->getSubscribers(); $notify_users = array(array(), null); foreach ($subscribers as $subscriber) { $notify_users[0][] = $subscriber->getId(); } $this->smarty->assign('notify_users', $notify_users); //EOF:mod 20110615 $discussion_data = $this->request->post('discussion'); if (!is_array($discussion_data)) { $discussion_data = array('name' => $this->active_discussion->getName(), 'body' => $this->active_discussion->getBody(), 'parent_id' => $this->active_discussion->getParentId(), 'milestone_id' => $this->active_discussion->getMilestoneId(), 'visibility' => $this->active_discussion->getVisibility(), 'tags' => $this->active_discussion->getTags()); } // if $this->smarty->assign('discussion_data', $discussion_data); if ($this->request->isSubmitted()) { db_begin_work(); $old_name = $this->active_discussion->getName(); $this->active_discussion->setAttributes($discussion_data); $save = $this->active_discussion->save(); if ($save && !is_error($save)) { db_commit(); //BOF: mod $this->active_discussion->register_departments(!empty($discussion_data['departments']) ? $discussion_data['departments'] : array()); //EOF: mod //BOF:mod 20110614 $subscribers = $this->request->post('notify_users'); if (!in_array($this->active_project->getLeaderId(), $subscribers)) { $subscribers[] = $this->active_project->getLeaderId(); } // if Subscriptions::subscribeUsers($subscribers, $this->active_discussion); $assignees_flag_data = $this->request->post('assignee'); $this->active_discussion->register_assignees_flag($assignees_flag_data); //EOF:mod 20110614 if ($this->request->getFormat() == FORMAT_HTML) { flash_success('Discussion ":name" has been updated', array('name' => $old_name)); $this->redirectToUrl($this->active_discussion->getViewUrl()); } else { $this->serveData($this->active_discussion, 'discussion'); } // if } else { db_rollback(); if ($this->request->getFormat() == FORMAT_HTML) { $this->smarty->assign('errors', $save); } else { $this->serveData($save); } // if } // if } // if }
$LastPost = $LastPost['ID']; $FirstPost = reset($Thread); $FirstPost = $FirstPost['ID']; if ($ThreadInfo['Posts'] <= $PerPage * $Page && $ThreadInfo['StickyPostID'] > $LastPost) { $LastPost = $ThreadInfo['StickyPostID']; } //Handle last read if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) { $DB->query("\n\t\tSELECT PostID\n\t\tFROM forums_last_read_topics\n\t\tWHERE UserID = '{$LoggedUser['ID']}'\n\t\t\tAND TopicID = '{$ThreadID}'"); list($LastRead) = $DB->next_record(); if ($LastRead < $LastPost) { $DB->query("\n\t\t\tINSERT INTO forums_last_read_topics\n\t\t\t\t(UserID, TopicID, PostID)\n\t\t\tVALUES\n\t\t\t\t('{$LoggedUser['ID']}', '{$ThreadID}', '" . db_string($LastPost) . "')\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\tPostID = '{$LastPost}'"); } } //Handle subscriptions $UserSubscriptions = Subscriptions::get_subscriptions(); if (empty($UserSubscriptions)) { $UserSubscriptions = array(); } if (in_array($ThreadID, $UserSubscriptions)) { $Cache->delete_value('subscriptions_user_new_' . $LoggedUser['ID']); } $QuoteNotificationsCount = $Cache->get_value('notify_quoted_' . $LoggedUser['ID']); if ($QuoteNotificationsCount === false || $QuoteNotificationsCount > 0) { $DB->query("\n\t\tUPDATE users_notify_quoted\n\t\tSET UnRead = false\n\t\tWHERE UserID = '{$LoggedUser['ID']}'\n\t\t\tAND Page = 'forums'\n\t\t\tAND PageID = '{$ThreadID}'\n\t\t\tAND PostID >= '{$FirstPost}'\n\t\t\tAND PostID <= '{$LastPost}'"); $Cache->delete_value('notify_quoted_' . $LoggedUser['ID']); } // Start printing View::show_header($ThreadInfo['Title'] . ' < ' . $Forums[$ForumID]['Name'] . ' < Forums', 'comments,subscriptions,bbcode', $IsDonorForum ? 'donor' : ''); ?> <div class="thin">
/** * Upload single file * * @param void * @return null */ function upload_single() { if ($this->request->isSubmitted()) { if (!File::canAdd($this->logged_user, $this->active_project)) { if ($this->request->isApiCall()) { $this->httpError(HTTP_ERR_FORBIDDEN, null, true, true); } else { die('error - upload not permitted'); } // if } // if $file_data = $this->request->post('file'); if (!is_array($file_data)) { $file_data = array('milestone_id' => $this->request->get('milestone_id'), 'visibility' => $this->active_project->getDefaultVisibility()); if (instance_of($this->active_category, 'Category')) { $file_data['parent_id'] = $this->active_category->getId(); } // if } // if $this->smarty->assign('file_data', $file_data); if ($this->request->isSubmitted()) { db_begin_work(); $this->active_file = new File(); $attached = attach_from_files($this->active_file, $this->logged_user); // Do we have an upload error? if (is_error($attached) || $attached != 1) { if ($this->request->isApiCall()) { $this->serveData(is_error($attached) ? $attached : new Error('0 files uploaded')); } else { die('error - nothing uploaded'); } // if } // if $this->active_file->setAttributes($file_data); if ($this->active_file->getName() == '') { $this->active_file->setName($this->active_file->pending_files[0]['name']); } // if $this->active_file->setRevision(1); $this->active_file->setProjectId($this->active_project->getId()); if (trim($this->active_file->getCreatedByName()) == '' || trim($this->active_file->getCreatedByEmail()) == '') { $this->active_file->setCreatedBy($this->logged_user); } // if $this->active_file->setState(STATE_VISIBLE); $save = $this->active_file->save(); if ($save && !is_error($save)) { if ($this->active_file->countRevisions() > 0) { $subscribers = array($this->logged_user->getId()); if (is_foreachable($this->request->post('notify_users'))) { $subscribers = array_merge($subscribers, $this->request->post('notify_users')); } else { $subscribers[] = $this->active_project->getLeaderId(); } // if if (!in_array($this->active_project->getLeaderId(), $subscribers)) { $subscribers[] = $this->active_project->getLeaderId(); } // if Subscriptions::subscribeUsers($subscribers, $this->active_file); db_commit(); $this->active_file->ready(); if ($this->request->isApiCall()) { $this->serveData($this->active_file, 'file'); } else { die('success'); // async } // if } else { if ($this->request->isApiCall()) { $this->httpError(HTTP_ERR_OPERATION_FAILED, null, true, true); } else { die('error - unable to attach file'); } // if } // if } else { if ($this->request->isApiCall()) { $this->serveData($save); } else { die('error - could not save file object'); // async } // if } // if } // if } else { if ($this->request->isApiCall()) { $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, true); } else { die('error - request is not POST request'); // async } // if } // if }