예제 #1
0
/**
 * Build menu
 *
 * @param Menu $menu
 * @param User $user
 * @return array
 */
function incoming_mail_handle_on_build_menu(&$menu, &$user)
{
    if (($user->isAdministrator() || $user->getSystemPermission('can_use_incoming_mail_frontend')) && ($count_pending = IncomingMails::countPending()) > 0) {
        $menu->addToGroup(array(new MenuItem('incoming_mail', lang('Inbox'), assemble_url('incoming_mail'), get_image_url('icon_menu.gif', INCOMING_MAIL_MODULE), $count_pending)), 'main');
    }
    // if
}
 /**
  * Get view url for resulting object
  *
  * @return string
  */
 function getResultingObjectUrl()
 {
     if ($this->getProjectObjectId()) {
         $object = ProjectObjects::findById($this->getProjectObjectId());
         if (instance_of($object, 'ProjectObject')) {
             return $object->getViewUrl();
         }
         // if
     } else {
         if ($this->getIncomingMailId()) {
             $object = IncomingMails::findById($this->getIncomingMailId());
             if (instance_of($object, 'IncomingMail')) {
                 return $object->getImportUrl();
             }
             // if
         }
     }
     // if
     return false;
 }
 /**
  * Tool for mass conflict resolution of selected emails
  * 
  * @param void
  * @return null
  */
 function mass_conflict_resolution()
 {
     if (!$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
     $action = $this->request->post('with_selected');
     if (trim($action) == '') {
         flash_error('Please select what you want to do with selected conflicts');
         $this->redirectToReferer(assemble_url('incoming_mail'));
     }
     // if
     $conflict_ids = $this->request->post('conflicts');
     $conflicts = IncomingMails::findByIds($conflict_ids);
     if (!is_foreachable($conflicts)) {
         flash_error("You didn't selected any conflicts for resolution");
         $this->redirectToReferer(assemble_url('incoming_mail'));
     }
     // if
     $updated = 0;
     switch ($action) {
         case 'delete':
             foreach ($conflicts as $conflict) {
                 $delete = $conflict->delete();
                 if ($delete && !is_error($delete)) {
                     $updated++;
                 }
                 // if
             }
             // foreach
             $message = ':count conflicts removed';
             break;
         default:
             break;
     }
     // switch
     flash_success($message, array('count' => $updated));
     $this->redirectToReferer(assemble_url('incoming_mail'));
 }
 /**
  * Find conflicts by ids
  *
  * @param array $ids
  * @return array
  */
 function findByIds($ids)
 {
     return IncomingMails::find(array('conditions' => array('id IN (?)', $ids), 'order' => 'created_on DESC'));
 }