public function rebuild($start_date = null, $end_date = null)
 {
     if (!$start_date) {
         $start_date = config_option('last_sharing_table_rebuild');
     }
     if ($start_date instanceof DateTimeValue) {
         $start_date = $start_date->toMySQL();
     }
     if ($end_date instanceof DateTimeValue) {
         $end_date = $end_date->toMySQL();
     }
     if ($end_date) {
         $end_cond = "AND updated_on <= '{$end_date}'";
     }
     try {
         $object_ids = Objects::instance()->findAll(array('id' => true, "conditions" => "updated_on >= '{$start_date}' {$end_cond}"));
         $obj_count = 0;
         DB::beginWork();
         foreach ($object_ids as $id) {
             $obj = Objects::findObject($id);
             if ($obj instanceof ContentDataObject) {
                 $obj->addToSharingTable();
                 $obj_count++;
             }
         }
         set_config_option('last_sharing_table_rebuild', DateTimeValueLib::now()->toMySQL());
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         Logger::log("Failed to rebuild sharing table: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
     }
     return $obj_count;
 }
 private function loadPanels($options)
 {
     if (!$this->panels) {
         $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId(), false);
         $this->panels = array();
         $sql = "\r\n\t\t\t\tSELECT * FROM " . TABLE_PREFIX . "tab_panels \r\n\t\t\t\tWHERE \r\n\t\t\t\t\tenabled = 1 AND\t\t\t\t\t\r\n\t\t\t\t\t( \t\r\n\t\t\t\t\t\tplugin_id IS NULL OR plugin_id=0 OR\r\n\t\t\t\t\t\tplugin_id IN (SELECT id FROM " . TABLE_PREFIX . "plugins WHERE is_installed = 1 AND is_activated = 1) \r\n\t\t\t\t\t)\r\n\t\t\t\t\tAND id IN (SELECT tab_panel_id FROM " . TABLE_PREFIX . "tab_panel_permissions WHERE permission_group_id IN ({$contact_pg_ids}))\r\n\t\t\t\tORDER BY ordering ASC ";
         $res = DB::execute($sql);
         while ($row = $res->fetchRow()) {
             $object = array("title" => lang($row['title']), "id" => $row['id'], "quickAddTitle" => lang($row['default_controller']), "refreshOnWorkspaceChange" => (bool) $row['refresh_on_context_change'], "defaultController" => $row['default_controller'], "defaultContent" => array("type" => "url", "data" => get_url($row['default_controller'], $row['default_action'])), "enabled" => $row['enabled'], "type" => $row['type'], "tabTip" => lang($row['title']));
             if (config_option('show_tab_icons')) {
                 $object["iconCls"] = $row['icon_cls'];
             }
             if ($row['initial_controller'] && $row['initial_action']) {
                 $object["initialContent"] = array("type" => "url", "data" => get_url($row['initial_controller'], $row['initial_action']));
             }
             if ($row['id'] == 'more-panel' && config_option('getting_started_step') >= 99) {
                 $object['closable'] = true;
                 if (!user_config_option('settings_closed')) {
                     $this->panels[] = $object;
                 }
             } else {
                 $this->panels[] = $object;
             }
         }
     }
     return $this->panels;
 }
 /**
  * Show dashboard index page
  *
  * @param void
  * @return null
  */
 function index()
 {
     trace(__FILE__, 'index() - begin');
     $logged_user = logged_user();
     $active_projects = $logged_user->getActiveProjects();
     $activity_log = null;
     $projects_activity_log = array();
     if (is_array($active_projects) && count($active_projects)) {
         $include_private = $logged_user->isMemberOfOwnerCompany();
         $include_silent = $logged_user->isAdministrator();
         $project_ids = array();
         foreach ($active_projects as $active_project) {
             $project_ids[] = $active_project->getId();
             $temp_project_logs = ApplicationLogs::getProjectLogs($active_project, $include_private, $include_silent, config_option('dashboard_project_logs_count', 7));
             if (isset($temp_project_logs) && is_array($temp_project_logs) && count($temp_project_logs)) {
                 $projects_activity_log[$temp_project_logs[0]->getCreatedOn()->getTimestamp()] = $temp_project_logs;
             }
             krsort($projects_activity_log);
         }
         // if
         $activity_log = ApplicationLogs::getOverallLogs($include_private, $include_silent, $project_ids, config_option('dashboard_logs_count', 15));
     }
     // if
     trace(__FILE__, 'index() - tpl_assign...');
     tpl_assign('today_milestones', $logged_user->getTodayMilestones());
     tpl_assign('late_milestones', $logged_user->getLateMilestones());
     tpl_assign('active_projects', $active_projects);
     tpl_assign('activity_log', $activity_log);
     tpl_assign('projects_activity_log', $projects_activity_log);
     // Sidebar
     tpl_assign('online_users', Users::getWhoIsOnline());
     tpl_assign('my_projects', $active_projects);
     $this->setSidebar(get_template_path('index_sidebar', 'dashboard'));
     trace(__FILE__, 'index() - end');
 }
Beispiel #4
0
  /**
  * If you need an activation routine run from the admin panel
  *   use the following pattern for the function:
  *
  *   <name_of_plugin>_activate
  *
  *  This is good for creation of database tables etc.
  */
  function time_activate() {
    $tp = TABLE_PREFIX;
    $cs = 'character set '.config_option('character_set', 'utf8');
    $co = 'collate '.config_option('collate', 'utf8_unicode_ci');
    $sql = "
CREATE TABLE IF NOT EXISTS `{$tp}project_times` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `project_id` int(10) unsigned default NULL,
  `task_list_id` int(11) default NULL,
  `task_id` int(11) default NULL,
  `name` varchar(100) $cs $co default NULL,
  `description` text $cs $co default NULL,
  `done_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `hours` float(4,2) NOT NULL default '0.00',
  `is_billable` tinyint(1) unsigned NOT NULL default '1',
  `assigned_to_company_id` smallint(10) NOT NULL default '0',
  `assigned_to_user_id` int(10) unsigned NOT NULL default '0',
  `is_private` tinyint(1) unsigned NOT NULL default '0',
  `is_closed` tinyint(1) unsigned NOT NULL default '0',
  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',
  `created_by_id` int(10) unsigned default NULL,
  `updated_on` datetime NOT NULL default '0000-00-00 00:00:00',
  `updated_by_id` int(10) unsigned default NULL,
  PRIMARY KEY  (`id`),
  KEY `project_id` (`project_id`),
  KEY `done_date` (`done_date`),
  KEY `created_on` (`created_on`)
);
";
    // create table
    DB::execute($sql);
    // TODO insert config options
    // TODO insert permission options
  }
Beispiel #5
0
 function purge_trash()
 {
     Env::useHelper("permissions");
     $days = config_option("days_on_trash", 0);
     $count = 0;
     if ($days > 0) {
         $date = DateTimeValueLib::now()->add("d", -$days);
         $objects = Objects::findAll(array("conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
         foreach ($objects as $object) {
             $concrete_object = Objects::findObject($object->getId());
             if (!$concrete_object instanceof ContentDataObject) {
                 continue;
             }
             if ($concrete_object instanceof MailContent && $concrete_object->getIsDeleted() > 0) {
                 continue;
             }
             try {
                 DB::beginWork();
                 if ($concrete_object instanceof MailContent) {
                     $concrete_object->delete(false);
                 } else {
                     $concrete_object->delete();
                 }
                 ApplicationLogs::createLog($concrete_object, ApplicationLogs::ACTION_DELETE);
                 DB::commit();
                 $count++;
             } catch (Exception $e) {
                 DB::rollback();
                 Logger::log("Error delting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
             }
         }
     }
     return $count;
 }
 function list_all()
 {
     ajx_current("empty");
     // Get all variables from request
     $start = array_var($_GET, 'start', 0);
     $limit = array_var($_GET, 'limit', config_option('files_per_page'));
     $order = array_var($_GET, 'sort');
     $order_dir = array_var($_GET, 'dir');
     $tag = array_var($_GET, 'tag');
     $action = array_var($_GET, 'action');
     $attributes = array("ids" => explode(',', array_var($_GET, 'ids')), "types" => explode(',', array_var($_GET, 'types')), "tag" => array_var($_GET, 'tagTag'), "accountId" => array_var($_GET, 'account_id'), "moveTo" => array_var($_GET, 'moveTo'), "mantainWs" => array_var($_GET, 'mantainWs'));
     //Resolve actions to perform
     $actionMessage = array();
     if (isset($action)) {
         $actionMessage = $this->resolveAction($action, $attributes);
         if ($actionMessage["errorCode"] == 0) {
             flash_success($actionMessage["errorMessage"]);
         } else {
             flash_error($actionMessage["errorMessage"]);
         }
     }
     // Get all emails and messages to display
     $project = active_project();
     list($messages, $pagination) = ProjectMessages::getMessages($tag, $project, $start, $limit, $order, $order_dir);
     $total = $pagination->getTotalItems();
     // Prepare response object
     $object = $this->prepareObject($messages, $start, $limit, $total);
     ajx_extra_data($object);
     tpl_assign("listing", $object);
 }
 /**
  * Show dashboard index page
  *
  * @param void
  * @return null
  */
 function index()
 {
     $logged_user = logged_user();
     $active_projects = $logged_user->getActiveProjects();
     $activity_log = null;
     if (is_array($active_projects) && count($active_projects)) {
         $include_private = $logged_user->isMemberOfOwnerCompany();
         $include_silent = $logged_user->isAdministrator();
         $project_ids = array();
         foreach ($active_projects as $active_project) {
             $project_ids[] = $active_project->getId();
         }
         // if
         $activity_log = ApplicationLogs::getOverallLogs($include_private, $include_silent, $project_ids, config_option('dashboard_logs_count', 15));
     }
     // if
     tpl_assign('today_milestones', $logged_user->getTodayMilestones());
     tpl_assign('late_milestones', $logged_user->getLateMilestones());
     tpl_assign('active_projects', $active_projects);
     tpl_assign('activity_log', $activity_log);
     // Sidebar
     tpl_assign('online_users', Users::getWhoIsOnline());
     tpl_assign('my_projects', $active_projects);
     $this->setSidebar(get_template_path('index_sidebar', 'dashboard'));
 }
 /**
  * Check if there is a new version of application available
  *
  * @param boolean $force When forced check will always construct the versions feed object
  *   try to fech the data and check for a new version. Version feed object is also returned
  * @return VersionFeed In case of error this function will return false
  */
 static function check($force = true)
 {
     $allow_url_fopen = strtolower(ini_get('allow_url_fopen'));
     if (function_exists('simplexml_load_file') && ($allow_url_fopen == '1' || $allow_url_fopen == 'on')) {
         // Execute once a day, if not forced check if we need to execute it now
         if (!$force) {
             if (config_option('upgrade_last_check_new_version', false)) {
                 return true;
                 // already have it checked and already have a new version
             }
             // if
             $last_check = config_option('upgrade_last_check_datetime');
             if ($last_check instanceof DateTimeValue && $last_check->getTimestamp() + 86400 > DateTimeValueLib::now()->getTimestamp()) {
                 return true;
                 // checked in the last day
             }
             // if
         }
         // if
         try {
             $versions_feed = new VersionsFeed();
             set_config_option('upgrade_last_check_datetime', DateTimeValueLib::now());
             set_config_option('upgrade_last_check_new_version', $versions_feed->hasNewVersions(product_version()));
             return $force ? $versions_feed : true;
         } catch (Exception $e) {
             return false;
         }
         // try
     } else {
         set_config_option('upgrade_check_enabled', false);
         return false;
     }
     // if
 }
 function getWebpages($project, $tag = '', $page = 1, $webpages_per_page = 10, $orderBy = 'title', $orderDir = 'ASC', $archived = false)
 {
     $orderDir = strtoupper($orderDir);
     if ($orderDir != "ASC" && $orderDir != "DESC") {
         $orderDir = "ASC";
     }
     if ($page < 0) {
         $page = 1;
     }
     //$conditions = logged_user()->isMemberOfOwnerCompany() ? '' : ' `is_private` = 0';
     if ($tag == '' || $tag == null) {
         $tagstr = "1=1";
     } else {
         $tagstr = "(SELECT count(*) FROM `" . TABLE_PREFIX . "tags` WHERE `" . TABLE_PREFIX . "project_webpages`.`id` = `" . TABLE_PREFIX . "tags`.`rel_object_id` AND `" . TABLE_PREFIX . "tags`.`tag` = " . DB::escape($tag) . " AND `" . TABLE_PREFIX . "tags`.`rel_object_manager` = 'ProjectWebpages' ) > 0 ";
     }
     $permission_str = ' AND (' . permissions_sql_for_listings(ProjectWebpages::instance(), ACCESS_LEVEL_READ, logged_user()) . ')';
     if ($project instanceof Project) {
         $pids = $project->getAllSubWorkspacesCSV(true);
         $project_str = " AND " . self::getWorkspaceString($pids);
     } else {
         $project_str = "";
     }
     if ($archived) {
         $archived_cond = " AND `archived_by_id` <> 0";
     } else {
         $archived_cond = " AND `archived_by_id` = 0";
     }
     $conditions = $tagstr . $permission_str . $project_str . $archived_cond;
     return ProjectWebpages::paginate(array("conditions" => $conditions, 'order' => DB::escapeField($orderBy) . " {$orderDir}"), config_option('files_per_page', 10), $page);
     // paginate
 }
 /**
  * Show and process add milestone form
  *
  * @access public
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_milestone');
     if (!ProjectMilestone::canAdd(logged_user(), active_project())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('milestone'));
     }
     // if
     $milestone_data = array_var($_POST, 'milestone');
     if (!is_array($milestone_data)) {
         $milestone_data = array('due_date' => DateTimeValueLib::now(), 'is_private' => config_option('default_private', false));
         // array
     }
     // if
     $milestone = new ProjectMilestone();
     tpl_assign('milestone_data', $milestone_data);
     tpl_assign('milestone', $milestone);
     if (is_array(array_var($_POST, 'milestone'))) {
         if (isset($_POST['milestone_due_date'])) {
             $milestone_data['due_date'] = DateTimeValueLib::makeFromString($_POST['milestone_due_date']);
         } else {
             $milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'milestone_due_date_month', 1), array_var($_POST, 'milestone_due_date_day', 1), array_var($_POST, 'milestone_due_date_year', 1970));
         }
         $assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));
         $milestone->setFromAttributes($milestone_data);
         if (!logged_user()->isMemberOfOwnerCompany()) {
             $milestone->setIsPrivate(false);
         }
         $milestone->setProjectId(active_project()->getId());
         $milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0));
         $milestone->setAssignedToUserId(array_var($assigned_to, 1, 0));
         try {
             DB::beginWork();
             $milestone->save();
             if (plugin_active('tags')) {
                 $milestone->setTagsFromCSV(array_var($milestone_data, 'tags'));
             }
             ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_ADD);
             DB::commit();
             // Send notification
             try {
                 if (array_var($milestone_data, 'send_notification') == 'checked') {
                     Notifier::milestoneAssigned($milestone);
                     // send notification
                 }
                 // if
             } catch (Exception $e) {
             }
             // try
             flash_success(lang('success add milestone', $milestone->getName()));
             $this->redirectTo('milestone');
         } catch (Exception $e) {
             DB::rollback();
             tpl_assign('error', $e);
         }
         // try
     }
     // if
 }
function send_password_expiration_reminders()
{
    $password_expiration_notification = config_option('password_expiration_notification', 0);
    if ($password_expiration_notification > 0) {
        _log("Sending password expiration reminders...");
        $count = UserPasswords::sendPasswordExpirationReminders();
        _log("{$count} password expiration reminders sent.");
    }
}
Beispiel #12
0
function reminders_activate()
{
    $tp = TABLE_PREFIX;
    $cs = 'character set ' . config_option('character_set', 'utf8');
    $co = 'collate ' . config_option('collation', 'utf8_unicode_ci');
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}reminders` (\n  `user_id` int(10) unsigned NOT NULL default '0',\n  `reminders_enabled` boolean,\n  `summarized_by` ENUM('all', 'project', 'milestone', 'task list', 'task') NOT NULL,\n  `days_in_future` int unsigned not null default '0',\n  `include_everyone` boolean,\n  `reminder_days` SET('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'),\n  `reports_enabled` boolean,\n  `reports_summarized_by` boolean,\n  `reports_include` boolean,\n  `reports_activity` boolean,\n  `report_day` ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'),  \n  PRIMARY KEY  (`user_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=" . DB_CHARSET;
    // create table
    DB::execute($sql);
}
 function getDueReminders($type = null)
 {
     if (isset($type)) {
         $extra = ' AND `type` = ' . DB::escape($type);
     } else {
         $extra = "";
     }
     return ObjectReminders::findAll(array('conditions' => array("`date` > '0000-00-00 00:00:00' AND `date` < ?" . $extra, DateTimeValueLib::now()), 'limit' => config_option('cron reminder limit', 100)));
 }
Beispiel #14
0
/**
 * If you need an activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_activate
 *
 *  This is good for creation of database tables etc.
 */
function tags_activate()
{
    $tp = TABLE_PREFIX;
    $cs = 'character set ' . config_option('character_set', 'utf8');
    $co = 'collate ' . config_option('collation', 'utf8_unicode_ci');
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}tags` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned NOT NULL default '0',\n  `tag` varchar(50) {$cs} {$co} NOT NULL default '',\n  `rel_object_id` int(10) unsigned NOT NULL default '0',\n  `rel_object_manager` varchar(50) {$cs} {$co} NOT NULL default '',\n  `created_on` datetime default NULL,\n  `created_by_id` int(10) unsigned NOT NULL default '0',\n  `is_private` tinyint(1) NOT NULL default '0',\n  PRIMARY KEY  (`id`),\n  KEY `project_id` (`project_id`),\n  KEY `tag` (`tag`),\n  KEY `object_id` (`rel_object_id`,`rel_object_manager`)\n);\n";
    // create table
    DB::execute($sql);
}
Beispiel #15
0
/**
 * If you need an activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_activate
 *
 *  This is good for creation of database tables etc.
 */
function form_activate()
{
    $tp = TABLE_PREFIX;
    $cs = 'character set ' . config_option('character_set', 'utf8');
    $co = 'collate ' . config_option('collation', 'utf8_unicode_ci');
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_forms` (\n  `id` smallint(5) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned NOT NULL default '0',\n  `name` varchar(50) NOT NULL default '',\n  `description` text {$cs} {$co} NOT NULL,\n  `success_message` text {$cs} {$co} NOT NULL,\n  `action` enum('add_comment','add_task') {$cs} {$co} NOT NULL default 'add_comment',\n  `in_object_id` int(10) unsigned NOT NULL default '0',\n  `created_on` datetime default NULL,\n  `created_by_id` int(10) unsigned NOT NULL default '0',\n  `updated_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `updated_by_id` int(10) unsigned NOT NULL default '0',\n  `is_visible` tinyint(1) unsigned NOT NULL default '0',\n  `is_enabled` tinyint(1) unsigned NOT NULL default '0',\n  `order` smallint(6) NOT NULL default '0',\n  PRIMARY KEY  (`id`)\n) TYPE=InnoDB  DEFAULT CHARSET=" . DB_CHARSET;
    // create table wiki_pages
    DB::execute($sql);
}
	private function loadPanels($options) {
		if (! $this->panels) {
			$contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId(),false);
			$this->panels = array();
			$sql = "
				SELECT * FROM " . TABLE_PREFIX . "tab_panels 
				WHERE 
					enabled = 1 AND					
					( 	
						type = 'system' OR 
						plugin_id IN (SELECT id FROM ".TABLE_PREFIX."plugins WHERE is_installed = 1 AND is_activated = 1) 
					)
					AND id IN (SELECT tab_panel_id FROM ".TABLE_PREFIX."tab_panel_permissions WHERE permission_group_id IN ($contact_pg_ids))
				ORDER BY ordering ASC ";
			
			$res = DB::execute ( $sql );
			while ( $row = $res->fetchRow () ) {
				 $object = array (
					"title" => lang($row ['title']), 
					"id" => $row ['id'], 
				 	"quickAddTitle" => lang ($row['default_controller']), 
					"refreshOnWorkspaceChange" => (bool) $row ['refresh_on_context_change'] , 
				 	"defaultController" => $row['default_controller'] ,
					"defaultContent" => array (
						"type" => "url", 
						"data" => get_url ( $row ['default_controller'], $row ['default_action'] ) 
					),
					"enabled" => $row ['enabled'], 
					"type" => $row ['type'],
				);
				
				if (config_option('show_tab_icons')) {
					$object["iconCls"] = $row ['icon_cls'];
				}

				
				if ( $row ['initial_controller'] && $row['initial_action'] ) {
					$object["initialContent"] = array (
						"type" => "url", 
						"data" => get_url ( $row ['initial_controller'], $row ['initial_action'] ) 
					);
				}
				/*
				if ( $row['title'] == "overview" ) {
					$object["initialContent"] = array (
						"type" => "url", 
						"data" => ROOT_URL 
					);
				}*/
				
				$this->panels [] = $object ;
			}
		}
		
		return $this->panels;
	}
function total_task_times_print_table($objects, $left, $options, $group_name, &$sub_total = 0, &$sub_total_billing = 0, &$sub_total_estimated = 0)
{
    echo '<div style="padding-left:' . $left . 'px;">';
    echo '<table class="reporting-table"><tr class="reporting-table-heading">';
    echo '<th>' . lang('date') . '</th>';
    echo '<th>' . lang('title') . '</th>';
    echo '<th>' . lang('description') . '</th>';
    echo '<th>' . lang('person') . '</th>';
    if (array_var($options, 'show_billing') == 'checked') {
        echo '<th class="right">' . lang('billing') . '</th>';
    }
    echo '<th class="right">' . lang('time') . '</th>';
    if ((array_var($options, 'timeslot_type') == 0 || array_var($options, 'timeslot_type') == 2) && array_var($options, 'show_estimated_time')) {
        echo '<th class="right">' . lang('estimated') . '</th>';
    }
    echo '</tr>';
    $sub_total = 0;
    $tasks = array();
    $alt_cls = "";
    foreach ($objects as $ts) {
        /* @var $ts Timeslot */
        echo "<tr {$alt_cls}>";
        echo "<td class='date'>" . format_date($ts->getStartTime()) . "</td>";
        echo "<td class='name'>" . ($ts->getRelObjectId() == 0 ? clean($ts->getObjectName()) : clean($ts->getRelObject()->getObjectName())) . "</td>";
        echo "<td class='name'>" . nl2br(clean($ts->getDescription())) . "</td>";
        echo "<td class='person'>" . clean($ts->getUser() instanceof Contact ? $ts->getUser()->getObjectName() : '') . "</td>";
        if (array_var($options, 'show_billing') == 'checked') {
            if ($ts->getIsFixedBilling()) {
                echo "<td class='nobr right'>" . config_option('currency_code', '$') . " " . number_format($ts->getFixedBilling(), 2) . "</td>";
                $sub_total_billing += $ts->getFixedBilling();
            } else {
                $min = $ts->getMinutes();
                echo "<td class='nobr right'>" . config_option('currency_code', '$') . " " . number_format($ts->getHourlyBilling() / 60 * $min, 2) . "</td>";
                $sub_total_billing += $ts->getHourlyBilling() / 60 * $min;
            }
        }
        $lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
        echo "<td class='time nobr right'>" . DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "hm", 60, $ts->getSubtract()) . "</td>";
        if ((array_var($options, 'timeslot_type') == 0 || array_var($options, 'timeslot_type') == 2) && $ts->getRelObject() instanceof ProjectTask && array_var($options, 'show_estimated_time')) {
            echo "<td class='time nobr right'>" . DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($ts->getRelObject()->getTimeEstimate() * 60), 'hm', 60) . "</td>";
            $task = $ts->getRelObject();
            //check if I have the estimated time of this task
            if (!in_array($task->getId(), $tasks)) {
                $sub_total_estimated += $task->getTimeEstimate();
            }
            $tasks[] = $task->getId();
        } elseif ((array_var($options, 'timeslot_type') == 0 || array_var($options, 'timeslot_type') == 2) && array_var($options, 'show_estimated_time')) {
            echo "<td class='time nobr right'> 0 </td>";
        }
        echo "</tr>";
        $sub_total += $ts->getMinutes();
        $alt_cls = $alt_cls == "" ? 'class="alt-row"' : "";
    }
    echo '</table></div>';
}
 /**
  * Validate before save
  *
  * @param array $errors
  * @return null
  */
 function validate(&$errors)
 {
     $mandatory_fields = config_option('mandatory_address_fields');
     if (is_array($mandatory_fields)) {
         foreach ($mandatory_fields as $mfield) {
             if (!$this->validatePresenceOf($mfield)) {
                 $errors[] = lang('address field is required', lang('address'), lang($mfield));
             }
         }
     }
 }
 function getNextDueReminders($type = null, DateTimeValue $start, DateTimeValue $end)
 {
     if (isset($type)) {
         $extra = ' AND `type` = ' . DB::escape($type);
     } else {
         $extra = "";
     }
     // get reminders that will not be shown in time if shown after $end time
     $reminders = ObjectReminders::findAll(array('conditions' => array("`date` > ? AND `date` < ? AND ADDDATE(`date`, INTERVAL `minutes_before` MINUTE) < ?" . $extra, $start, $end, $end), 'limit' => config_option('cron reminder limit', 100)));
     return $reminders;
 }
Beispiel #20
0
/**
 * If you need an activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_activate
 *
 *  This is good for creation of database tables etc.
 */
function wiki_activate()
{
    $cs = 'character set ' . config_option('character_set', 'utf8');
    $co = 'collate ' . config_option('collation', 'utf8_unicode_ci');
    $sql = "\nCREATE TABLE IF NOT EXISTS `" . TABLE_PREFIX . "wiki_pages` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `parent_id` int(10) unsigned NOT NULL default 0,\n  `revision` int(10) unsigned default NULL,\n  `project_id` int(10) unsigned default NULL,\n  `project_sidebar` tinyint(1) unsigned default '0',\n  `project_index` tinyint(1) unsigned default '0',\n  `publish` tinyint(1) unsigned default '0',\n  `locked` tinyint(1) default '0',\n  `locked_by_id` int(10) unsigned default NULL,\n  `locked_on` datetime default '0000-00-00 00:00:00',\n  PRIMARY KEY  (`id`),\n  UNIQUE INDEX `subpages` (`parent_id`, `id`)\n);";
    // create table wiki_pages
    DB::execute($sql);
    $sql = "\nCREATE TABLE IF NOT EXISTS `" . TABLE_PREFIX . "wiki_revisions` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned default NULL,\n  `page_id` int(10) unsigned default NULL,\n  `revision` tinyint(3) unsigned default NULL,\n  `name` varchar(50) {$cs} {$co}  NOT NULL,\n  `content` text {$cs} {$co}  NOT NULL,\n  `created_on` datetime default NULL,\n  `created_by_id` int(10) unsigned default NULL,\n  `log_message` varchar(255) {$cs} {$co}  default NULL,\n  PRIMARY KEY  (`id`)\n);";
    // create table wiki_revisions
    DB::execute($sql);
}
Beispiel #21
0
/**
 * If you need an activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_activate
 *
 *  This is good for creation of database tables etc.
 */
function files_activate()
{
    $tp = TABLE_PREFIX;
    $cs = 'character set ' . config_option('character_set', 'utf8');
    $co = 'collate ' . config_option('collation', 'utf8_unicode_ci');
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_file_revisions` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `file_id` int(10) unsigned NOT NULL default '0',\n  `file_type_id` smallint(5) unsigned NOT NULL default '0',\n  `repository_id` varchar(40) {$cs} {$co} NOT NULL default '',\n  `filename` varchar(100) {$cs} {$co} NOT NULL default '',\n  `thumb_filename` varchar(44) {$cs} {$co} default NULL,\n  `revision_number` int(10) unsigned NOT NULL default '0',\n  `comment` text {$cs} {$co},\n  `type_string` varchar(140) {$cs} {$co} NOT NULL default '',\n  `filesize` int(10) unsigned NOT NULL default '0',\n  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `created_by_id` int(10) unsigned default NULL,\n  `updated_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `updated_by_id` int(10) unsigned default NULL,\n  PRIMARY KEY  (`id`),\n  KEY `file_id` (`file_id`),\n  KEY `updated_on` (`updated_on`),\n  KEY `revision_number` (`revision_number`)\n);\n";
    DB::execute($sql);
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_files` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned NOT NULL default '0',\n  `folder_id` smallint(5) unsigned NOT NULL default '0',\n  `filename` varchar(100) {$cs} {$co} NOT NULL default '',\n  `description` text {$cs} {$co},\n  `is_private` tinyint(1) unsigned NOT NULL default '0',\n  `is_important` tinyint(1) unsigned NOT NULL default '0',\n  `is_locked` tinyint(1) unsigned NOT NULL default '0',\n  `is_visible` tinyint(1) unsigned NOT NULL default '0',\n  `expiration_time` datetime NOT NULL default '0000-00-00 00:00:00',\n  `comments_enabled` tinyint(1) unsigned NOT NULL default '0',\n  `anonymous_comments_enabled` tinyint(1) unsigned NOT NULL default '0',\n  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `created_by_id` int(10) unsigned default '0',\n  `updated_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `updated_by_id` int(10) unsigned default '0',\n  PRIMARY KEY  (`id`),\n  KEY `project_id` (`project_id`)\n);\n";
    DB::execute($sql);
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_folders` (\n  `id` smallint(5) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned NOT NULL default '0',\n  `name` varchar(50) {$cs} {$co} NOT NULL default '',\n  PRIMARY KEY  (`id`),\n  UNIQUE KEY `project_id` (`project_id`,`name`)\n);\n";
    DB::execute($sql);
}
 /**
  * 
  * Returns list of Dimensions where objects with $content_object_type_id can be located
  * @param $content_object_type_id
  * @author Pepe
  */
 static function getAllowedDimensions($content_object_type_id)
 {
     $enabled_dimensions_sql = "AND false";
     $enabled_dimensions_ids = implode(',', config_option('enabled_dimensions'));
     if ($enabled_dimensions_ids != "") {
         $enabled_dimensions_sql = "AND d.id IN ({$enabled_dimensions_ids})";
     }
     $sql = "\r\n\t\t\tSELECT\r\n\t\t\t\tdotc.dimension_id AS dimension_id,\r\n\t\t\t\td.name as dimension_name,\r\n\t\t\t\td.code as dimension_code,\r\n\t\t\t\td.options as dimension_options,\r\n\t\t\t\t(dotc.is_required OR d.is_required) AS is_required,\r\n\t\t\t\tdotc.is_multiple AS is_multiple,\r\n\t\t\t\td.is_manageable AS is_manageable\r\n\t\t\t\r\n\t\t\tFROM \r\n\t\t\t\t" . TABLE_PREFIX . "dimension_object_type_contents dotc\r\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "dimensions d ON d.id = dotc.dimension_id\r\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "object_types t ON t.id = dotc.dimension_object_type_id\r\n\t\t\t\r\n\t\t\tWHERE \r\n\t\t\t\tcontent_object_type_id = {$content_object_type_id}\r\n\t\t\t\t{$enabled_dimensions_sql}\r\n\t\t\tGROUP BY dimension_id\r\n\t\t\tORDER BY is_required DESC, d.default_order ASC, dimension_name ASC\r\n\t\t\r\n\t\t";
     $dimensions = array();
     $res = DB::execute($sql);
     return $res->fetchAll();
 }
Beispiel #23
0
/**
 * If you need an activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_activate
 *
 *  This is good for creation of database tables etc.
 */
function links_activate()
{
    $cs = 'character set ' . config_option('character_set', 'utf8');
    $co = 'collate ' . config_option('collation', 'utf8_unicode_ci');
    $sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_PREFIX . "project_links` (\n        `id` int(10) unsigned NOT NULL auto_increment,\n        `project_id` int(10) unsigned NOT NULL default '0',\n        `folder_id` INT( 10 ) NOT NULL DEFAULT 0,\n        `title` varchar(50) {$cs} {$co} NOT NULL default '',\n        `url` text {$cs} {$co},\n        `description` TEXT {$cs} {$co} DEFAULT '',\n        `logo_file` VARCHAR(50) {$cs} {$co} DEFAULT '',\n        `created_on` datetime NOT NULL default '0000-00-00 00:00:00',\n        `created_by_id` int(10) unsigned default NULL,\n        PRIMARY KEY  (`id`),\n        KEY `created_on` (`created_on`),\n        KEY `project_id` (`project_id`)\n      );";
    // create table
    DB::execute($sql);
    //add_permission('links', PermissionManager::CAN_ACCESS);
    //add_permission('links', PermissionManager::CAN_ADD);  // = add/edit
    //add_permission('links', PermissionManager::CAN_DELETE);
    //add_permission('links', PermissionManager::CAN_VIEW);
}
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $groups = PermissionGroups::getNonRolePermissionGroups();
     $selected = config_option('default_guest_user_group');
     $options = array();
     $attrs = $selected == 0 ? array('selected' => 'selected') : array();
     $options[] = option_tag(lang('none'), 0, $attrs);
     foreach ($groups as $group) {
         $attrs = $selected == $group->getId() ? array('selected' => 'selected') : array();
         $options[] = option_tag(clean($group->getName()), $group->getId(), $attrs);
     }
     echo select_box($control_name, $options);
 }
Beispiel #25
0
/**
 * This function will render system notices for this user
 *
 * @param User $user
 * @return string
 */
function render_system_notices(User $user)
{
    if (!$user->isAdministrator()) {
        return;
    }
    $system_notices = array();
    if (config_option('upgrade_check_enabled', false) && config_option('upgrade_last_check_new_version', false)) {
        $system_notices[] = lang('new version available', get_url('administration', 'upgrade'));
    }
    if (count($system_notices)) {
        tpl_assign('_system_notices', $system_notices);
        return tpl_fetch(get_template_path('system_notices', 'application'));
    }
    // if
}
 /**
  * Show project overview
  *
  * @param void
  * @return null
  */
 function overview()
 {
     if (!logged_user()->isProjectUser(active_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $this->addHelper('textile');
     $project = active_project();
     tpl_assign('project_log_entries', $project->getProjectLog(config_option('project_logs_per_page', 20)));
     tpl_assign('late_milestones', $project->getLateMilestones());
     tpl_assign('today_milestones', $project->getTodayMilestones());
     tpl_assign('upcoming_milestones', $project->getUpcomingMilestones());
 }
 /**
  * Return project messages
  *
  * @access public
  * @param void
  * @return array
  */
 function index()
 {
     $this->addHelper('textile');
     $page = (int) array_var($_GET, 'page', 1);
     if ($page < 0) {
         $page = 1;
     }
     $conditions = logged_user()->isMemberOfOwnerCompany() ? array('`project_id` = ?', active_project()->getId()) : array('`project_id` = ? AND `is_private` = ?', active_project()->getId(), 0);
     list($messages, $pagination) = ProjectMessages::paginate(array('conditions' => $conditions, 'order' => '`created_on` DESC'), config_option('messages_per_page', 10), $page);
     // paginate
     tpl_assign('messages', $messages);
     tpl_assign('messages_pagination', $pagination);
     tpl_assign('important_messages', active_project()->getImportantMessages());
     $this->setSidebar(get_template_path('index_sidebar', 'message'));
 }
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $dimensions = Dimensions::instance()->findAll(array('conditions' => '`is_manageable` = 1'));
     $options = array();
     $option_attributes = $this->getValue() == 0 ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('none'), 0, $option_attributes);
     foreach ($dimensions as $dim) {
         /* @var $dim Dimension */
         if (in_array($dim->getId(), config_option('enabled_dimensions'))) {
             $dim_name = $dim->getName();
             $option_attributes = $this->getValue() == $dim->getId() ? array('selected' => 'selected') : null;
             $options[] = option_tag($dim_name, $dim->getId(), $option_attributes);
         }
     }
     return select_box($control_name, $options);
 }
Beispiel #29
0
/**
 * If you need an activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_activate
 *
 *  This is good for creation of database tables etc.
 */
function files_activate()
{
    $tp = TABLE_PREFIX;
    $cs = 'character set ' . config_option('character_set', 'utf8');
    $co = 'collate ' . config_option('collation', 'utf8_unicode_ci');
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_file_revisions` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `file_id` int(10) unsigned NOT NULL default '0',\n  `file_type_id` smallint(5) unsigned NOT NULL default '0',\n  `repository_id` varchar(40) {$cs} {$co} NOT NULL default '',\n  `filename` varchar(100) {$cs} {$co} NOT NULL default '',\n  `thumb_filename` varchar(44) {$cs} {$co} default NULL,\n  `revision_number` int(10) unsigned NOT NULL default '0',\n  `comment` text {$cs} {$co},\n  `type_string` varchar(140) {$cs} {$co} NOT NULL default '',\n  `filesize` int(10) unsigned NOT NULL default '0',\n  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `created_by_id` int(10) unsigned default NULL,\n  `updated_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `updated_by_id` int(10) unsigned default NULL,\n  PRIMARY KEY  (`id`),\n  KEY `file_id` (`file_id`),\n  KEY `updated_on` (`updated_on`),\n  KEY `revision_number` (`revision_number`)\n);\n";
    DB::execute($sql);
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_files` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned NOT NULL default '0',\n  `folder_id` smallint(5) unsigned NOT NULL default '0',\n  `filename` varchar(100) {$cs} {$co} NOT NULL default '',\n  `description` text {$cs} {$co},\n  `is_private` tinyint(1) unsigned NOT NULL default '0',\n  `is_important` tinyint(1) unsigned NOT NULL default '0',\n  `is_locked` tinyint(1) unsigned NOT NULL default '0',\n  `is_visible` tinyint(1) unsigned NOT NULL default '0',\n  `expiration_time` datetime NOT NULL default '0000-00-00 00:00:00',\n  `comments_enabled` tinyint(1) unsigned NOT NULL default '0',\n  `anonymous_comments_enabled` tinyint(1) unsigned NOT NULL default '0',\n  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `created_by_id` int(10) unsigned default '0',\n  `updated_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `updated_by_id` int(10) unsigned default '0',\n  PRIMARY KEY  (`id`),\n  KEY `project_id` (`project_id`)\n);\n";
    DB::execute($sql);
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_folders` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned NOT NULL default '0',\n  `name` varchar(50) {$cs} {$co} NOT NULL default '',\n  `parent_id` int(10) unsigned NOT NULL default '0',\n  PRIMARY KEY  (`id`),\n  UNIQUE KEY `project_id` (`project_id`,`name`)\n);\n";
    DB::execute($sql);
    $sql = "\nINSERT INTO `{$tp}config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES ('features', 'files_show_icons', '1', 'BoolConfigHandler', 0, 0, 'Show file icons');\n";
    DB::execute($sql);
    $sql = "\nINSERT INTO `{$tp}config_options` (`category_name`, `name`, `value`, `config_handler_class`, `is_system`, `option_order`, `dev_comment`) VALUES ('features', 'files_show_thumbnails', '1', 'BoolConfigHandler', 0, 0, 'Show file thumbnails');\n";
    DB::execute($sql);
}
Beispiel #30
0
/**
 * If you need an activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_activate
 *
 *  This is good for creation of database tables etc.
 */
function tickets_activate()
{
    $tp = TABLE_PREFIX;
    $cs = 'character set ' . config_option('character_set', 'utf8');
    $co = 'collate ' . config_option('collation', 'utf8_unicode_ci');
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_categories` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned NOT NULL default '0',\n  `name` varchar(50) {$cs} {$co} NOT NULL default '',\n  `description` varchar(255) {$cs} {$co} default NULL,\n  PRIMARY KEY  (`id`)\n);\n";
    DB::execute($sql);
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_tickets` (\n  `id` int(10) unsigned NOT NULL auto_increment,\n  `project_id` int(10) unsigned NOT NULL default '0',\n  `category_id` int(10) unsigned default NULL,\n  `assigned_to_company_id` smallint(5) unsigned default NULL,\n  `assigned_to_user_id` int(10) unsigned default NULL,\n  `summary` varchar(200)  {$cs} {$co} NOT NULL default '',\n  `type` enum('defect', 'enhancement', 'feature request') {$cs} {$co} NOT NULL default 'defect',\n  `description` text {$cs} {$co},\n  `priority` enum('critical', 'major', 'minor', 'trivial') {$cs} {$co} NOT NULL default 'major',\n  `state` enum( 'opened', 'confirmed', 'not reproducable', 'test and confirm', 'fixed', 'closed', 'none' ) {$cs} {$co} NOT NULL DEFAULT 'opened',\n  `is_private` tinyint(1) NOT NULL default '0',\n  `closed_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `closed_by_id` int(10) default NULL,\n  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `created_by_id` int(10) unsigned default NULL,\n  `updated_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `updated_by_id` int(10) default NULL,\n  `updated` enum('settings', 'comment', 'attachment', 'open', 'closed') {$cs} {$co} default NULL,\n  PRIMARY KEY  (`id`),\n  KEY `created_on` (`created_on`),\n  KEY `closed_on` (`closed_on`),\n  KEY `project_id` (`project_id`)\n);\n";
    DB::execute($sql);
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_ticket_changes` (\n  `id` int(11) unsigned NOT NULL auto_increment,\n  `ticket_id` int(11) unsigned NOT NULL default '0',\n  `type` enum('status', 'priority', 'assigned to', 'summary', 'category', 'type', 'private', 'comment', 'attachment', '') {$cs} {$co} NOT NULL,\n  `from_data` varchar(255) {$cs} {$co} NOT NULL default '',\n  `to_data` varchar(255) {$cs} {$co} NOT NULL default '',\n  `created_on` datetime NOT NULL default '0000-00-00 00:00:00',\n  `created_by_id` int(10) default NULL,\n  PRIMARY KEY  (`id`),\n  KEY `created_on` (`created_on`),\n  KEY `ticket_id` (`ticket_id`)\n);\n";
    DB::execute($sql);
    $sql = "\nCREATE TABLE IF NOT EXISTS `{$tp}project_ticket_subscriptions` (\n  `ticket_id` int(10) unsigned NOT NULL default '0',\n  `user_id` int(10) unsigned NOT NULL default '0',\n  PRIMARY KEY  (`ticket_id`,`user_id`)\n);\n";
    // create table
    DB::execute($sql);
    // TODO add permissions
}