示例#1
0
 /** cron log, INTERNAL
  *  daily cron
  *
  * @return array results of running this cron
  */
 function _cronPageImpressionAndUserActivity()
 {
     include_once 'functions/misc_functions.php';
     $time_start = getmicrotime();
     $cron_array = array();
     $cron_array['title'] = 'page impression and user activity cron';
     $cron_array['description'] = 'count page impressions and user activity';
     $cron_array['success'] = true;
     $cron_array['success_text'] = 'cron failed';
     $log_manager = $this->_environment->getLogManager();
     $room_list = $this->getRoomList();
     $count_rooms = 0;
     if ($room_list->isNotEmpty()) {
         $room_item = $room_list->getFirst();
         while ($room_item) {
             // get latest timestamp of page impressions and user actitivty
             // from extra field PIUA_LAST
             $piua_last = $room_item->getPageImpressionAndUserActivityLast();
             if (!empty($piua_last)) {
                 $oldest_date = $piua_last;
             } else {
                 // if there is no entry take creation_date
                 $creation_date = $room_item->getCreationDate();
                 $oldest_date = getYearFromDateTime($creation_date) . getMonthFromDateTime($creation_date) . getDayFromDateTime($creation_date);
             }
             $current_date = getCurrentDate();
             $day_diff = getDifference($oldest_date, $current_date);
             $pi_array = $room_item->getPageImpressionArray();
             $ua_array = $room_item->getUserActivityArray();
             $pi_input = array();
             $ua_input = array();
             // for each day, get page impressions and user activity
             for ($i = 1; $i < $day_diff; $i++) {
                 $log_manager->resetLimits();
                 $log_manager->setContextLimit($room_item->getItemID());
                 $log_manager->setRequestLimit("commsy.php");
                 $older_limit_stamp = datetime2Timestamp(date("Y-m-d 00:00:00")) - ($i - 1) * 86400;
                 $older_limit = date('Y-m-d', $older_limit_stamp);
                 $log_manager->setTimestampOlderLimit($older_limit);
                 $log_manager->setTimestampNotOlderLimit($i);
                 $pi_input[] = $log_manager->getCountAll();
                 $ua_input[] = $log_manager->countWithUserDistinction();
             }
             // put actual date in extra field PIUA_LAST
             $room_item->setPageImpressionAndUserActivityLast($current_date);
             $room_item->setPageImpressionArray(array_merge($pi_input, $pi_array));
             $room_item->setUserActivityArray(array_merge($ua_input, $ua_array));
             $room_item->saveWithoutChangingModificationInformation();
             $count_rooms++;
             unset($room_item);
             $room_item = $room_list->getNext();
         }
     }
     unset($room_list);
     unset($log_manager);
     $cron_array['success_text'] = 'count page impressions and user activity of ' . $count_rooms . ' rooms';
     $time_end = getmicrotime();
     $time = round($time_end - $time_start, 0);
     $cron_array['time'] = $time;
     return $cron_array;
 }
示例#2
0
文件: cs_item.php 项目: a2call/commsy
 public function getDataAsXMLForFlash()
 {
     $type = $this->getType();
     if ($type == CS_LABEL_TYPE) {
         $type = $this->getLabelType();
     }
     $retour = '      <item>' . LF;
     if (!empty($type)) {
         $retour .= '         <type><![CDATA[' . $type . ']]></type>' . LF;
     }
     foreach ($this->_data as $key => $value) {
         if ($key == 'item_id' or $key == 'title' or $key == 'name' or $key == 'first_item_id' or $key == 'second_item_id' or $key == 'first_item_type' or $key == 'second_item_type' or $key == 'description') {
             if ($key == 'item_id') {
                 $key = 'id';
             }
             if ($key == 'first_item_id') {
                 $key = 'first_id';
             }
             if ($key == 'second_item_id') {
                 $key = 'second_id';
             }
             if ($key == 'first_item_type') {
                 $key = 'first_type';
             }
             if ($key == 'second_item_type') {
                 $key = 'second_type';
             }
             if ($key == 'description') {
                 // AS XML ???
                 $value = preg_replace('~\\(:(.*?):\\)~eu', '', $value);
                 // entfernt medien einbindung
                 $value = strip_tags($value);
                 // entfernt html tags
                 $value = html_entity_decode($value, ENT_NOQUOTES, 'UTF-8');
                 // wandelt &quot; usw. in lesbare Zeichen um
             }
             if (!empty($value)) {
                 $retour .= '         <' . $key . '><![CDATA[' . $value . ']]></' . $key . '>' . LF;
             }
         }
     }
     # url
     if ($type != CS_LINKITEM_TYPE) {
         $retour .= '         <url><![CDATA[' . $this->getItemUrl() . ']]></url>' . LF;
     }
     if ($type == CS_LINKITEM_TYPE or $type == CS_MATERIAL_TYPE) {
         if ($this->getPosX() > 0) {
             $retour .= '         <x><![CDATA[' . $this->getPosX() . ']]></x>' . LF;
         }
         if ($this->getPosY() > 0) {
             $retour .= '         <y><![CDATA[' . $this->getPosY() . ']]></y>' . LF;
         }
     }
     # images
     $image = '';
     $file_list = $this->getFileList();
     if (isset($file_list) and $file_list->isNotEmpty()) {
         $retour .= '         <list>' . LF;
         $retour .= '            <type>file</type>' . LF;
         $file_item = $file_list->getFirst();
         while ($file_item) {
             $retour .= '               <item>' . LF;
             $retour .= '                  <type><![CDATA[file]]></type>' . LF;
             $retour .= '                  <id><![CDATA[' . $file_item->getFileID() . ']]></id>' . LF;
             $retour .= '                  <mime><![CDATA[' . $file_item->getMime() . ']]></mime>' . LF;
             $retour .= '                  <url><![CDATA[' . $file_item->getItemUrl() . ']]></url>' . LF;
             $retour .= '                  <icon><![CDATA[' . $file_item->getIconUrl() . ']]></icon>' . LF;
             $retour .= '               </item>' . LF;
             $file_item = $file_list->getNext();
         }
         $retour .= '         </list>' . LF;
     }
     if ($this->isA(CS_MATERIAL_TYPE)) {
         $author = $this->getAuthor();
         if (!empty($author)) {
             $retour .= '         <list>' . LF;
             $retour .= '            <type>author</type>' . LF;
             $author_array = explode(';', $this->getAuthor());
             foreach ($author_array as $value) {
                 $retour .= '            <item>' . LF;
                 $retour .= '               <type>author</type>' . LF;
                 $retour .= '               <fullname><![CDATA[' . trim($value) . ']]></fullname>' . LF;
                 $retour .= '            </item>' . LF;
             }
             $retour .= '         </list>' . LF;
         } else {
             $mod_list = $this->getModifierList();
             if (isset($mod_list) and $mod_list->isNotEmpty()) {
                 $retour .= '         <list>' . LF;
                 $retour .= '            <type>author</type>' . LF;
                 $mod_item = $mod_list->getFirst();
                 while ($mod_item) {
                     if (isset($mod_item)) {
                         $retour .= '            <item>' . LF;
                         $retour .= '               <type>author</type>' . LF;
                         $retour .= '               <fullname><![CDATA[' . trim($mod_item->getFullname()) . ']]></fullname>' . LF;
                         $retour .= '               <firstname><![CDATA[' . trim($mod_item->getFirstname()) . ']]></firstname>' . LF;
                         $retour .= '               <lastname><![CDATA[' . trim($mod_item->getLastname()) . ']]></lastname>' . LF;
                         $retour .= '            </item>' . LF;
                     }
                     $mod_item = $mod_list->getNext();
                 }
                 $retour .= '         </list>' . LF;
             }
         }
         $date = $this->getPublishingDate();
         if (!empty($date)) {
             $retour .= '         <date>' . LF;
             $retour .= '            <year>' . $date . '</year>' . LF;
             $retour .= '         </date>' . LF;
         } else {
             $mod_date = $this->getModificationDate();
             include_once 'functions/date_functions.php';
             $retour .= '         <date>' . LF;
             $retour .= '            <year>' . getYearFromDateTime($mod_date) . '</year>' . LF;
             $retour .= '            <month>' . getMonthFromDateTime($mod_date) . '</month>' . LF;
             $retour .= '            <day>' . getDayFromDateTime($mod_date) . '</day>' . LF;
             $retour .= '         </date>' . LF;
         }
     }
     $retour .= '      </item>' . LF;
     return $retour;
 }