Example #1
0
 /**
  * get an existing receipt
  */
 public static function get($receipt_id)
 {
     self::getCustomFields();
     $receipt = new self($receipt_id);
     if ($receipt->exists()) {
         return $receipt;
     } else {
         return NULL;
     }
 }
 public function getThumbnail()
 {
     if (!$this->_thumbnail) {
         $thumbnail = new self($this->getRelativePathDirectory() . '/' . sfSympalConfig::get('assets', 'thumbnails_dir') . '/' . $this->getName());
         if ($thumbnail->exists()) {
             $this->_thumbnail = $thumbnail;
         }
     }
     return $this->_thumbnail;
 }
Example #3
0
 public static function get($id, $vault)
 {
     $job = new self($id, $vault);
     if (!$job->exists()) {
         return false;
     }
     switch ($job->getAction()) {
         case 'InventoryRetrieval':
             return new InventoryJob($id, $vault);
         case 'ArchiveRetrieval':
             return new ArchiveJob($id, $vault);
     }
     return false;
 }
 public static function login($kwargs)
 {
     if (!array_key_exists('email', $kwargs) || !array_key_exists('password', $kwargs)) {
         return FALSE;
     }
     $credential = new self();
     $credential->where('email', $kwargs['email'])->get();
     if (!$credential->exists()) {
         return 'id or password are invalid';
         ///
     }
     $enc_pass = self::encrypt_password($kwargs['password']);
     if (strcasecmp($enc_pass, $credential->password) != 0) {
         return 'id or password are invalid';
         ///
     }
     // autologin
     if (array_key_exists('autologin', $kwargs) && $kwargs['autologin']) {
         $ci =& get_instance();
         $ci->load->helper('cookie');
         set_cookie(array('name' => 'autologin_native', 'value' => serialize(array('email' => $credential->email, 'password' => $enc_pass)), 'expire' => 86500));
     }
     return $credential;
 }
Example #5
0
 protected static function lasteditStatic($name)
 {
     $self = new self();
     if ($self->exists($name)) {
         return filemtime($self->path($name));
     } else {
         throw new \InvalidArgumentException("There is no file calls {$name}");
     }
 }
 /**
  * Retrieves an sfSympalAssetImageObject representing a thumbnail version
  * of this image
  *
  * @param integer $width The width for the thumbnail
  * @param integer $height The height for the thumbnail
  * @param string $method The method for thumbnailing (fit, scale, inflate, deflate, left, right, top, bottom, center)
  *
  * @return sfSympalAssetImageObject
  */
 public function getThumbnail($width = null, $height = null, $method = null)
 {
     $width = $width === null ? sfSympalConfig::get('assets', 'thumbnails_default_width', 64) : $width;
     $height = $height === null ? sfSympalConfig::get('assets', 'thumbnails_default_height', 64) : $height;
     $method = $method === null ? sfSympalConfig::get('assets', 'thumbnails_method', 'fit') : $method;
     $thumbnailKey = $width . '_' . $height . '_' . $method;
     if (!isset($this->_thumbnails[$thumbnailKey])) {
         $thumbnailPath = $this->getThumbnailDirectory($width, $height, $method) . '/' . $this->getName();
         if (!file_exists($thumbnailPath)) {
             // the thumbnail file doesn't exist, create it
             $this->_generateThumbnail($width, $height, $method);
         }
         $thumbnail = new self($this->getRelativePathDirectory() . '/' . sfSympalConfig::get('assets', 'thumbnails_dir') . '/' . $this->getThumbnailSubdirectory($width, $height, $method) . '/' . $this->getName());
         if ($thumbnail->exists()) {
             $this->_thumbnails[$thumbnailKey] = $thumbnail;
         } else {
             $this->_thumbnails[$thumbnailKey] = false;
         }
     }
     return $this->_thumbnails[$thumbnailKey];
 }
 /**
  * @param $user_id
  * @param $notification_name
  *
  * @return bool
  */
 public static function needShowNotification($user_id, $notification_name)
 {
     $notification = new self();
     $notification->where(['user_id' => $user_id, 'notification' => $notification_name])->get(1);
     return $notification->exists() ? $notification->show : true;
 }
Example #8
0
 public static function factory()
 {
     if (file_exists(INSTALL_PATH . self::CONFIG_XML)) {
         $xmlfile = file_get_contents(INSTALL_PATH . self::CONFIG_XML);
         $obj = new self($xmlfile);
         // 8月14日以降に追加した設定項目の自動生成
         // キーワード自動録画の録画モード
         if ($obj->exists("autorec_mode") == 0) {
             $obj->autorec_mode = 0;
             $obj->save();
         }
         // CSの録画
         if ($obj->exists("cs_rec_flg") == 0) {
             $obj->cs_rec_flg = 0;
             $obj->save();
         }
         return $obj;
     } else {
         // 初回起動
         $xmlfile = '<?xml version="1.0" encoding="UTF-8" ?><epgrec></epgrec>';
         $xml = new self($xmlfile);
         // 旧config.phpを読み取って設定
         if (defined("SPOOL")) {
             $xml->spool = SPOOL;
         } else {
             $xml->spool = "/video";
         }
         if (defined("THUMBS")) {
             $xml->thumbs = THUMBS;
         } else {
             $xml->thumbs = "/thumbs";
         }
         if (defined("INSTALL_URL")) {
             $xml->install_url = INSTALL_URL;
         } else {
             $xml->install_url = "http://localhost/epgrec";
         }
         if (defined("BS_TUNERS")) {
             $xml->bs_tuners = BS_TUNERS;
         } else {
             $xml->bs_tuners = 0;
         }
         if (defined("GR_TUNERS")) {
             $xml->gr_tuners = GR_TUNERS;
         } else {
             $xml->gr_tuners = 1;
         }
         if (defined("CS_REC_FLG")) {
             $xml->cs_rec_flg = CS_REC_FLG;
         } else {
             $xml->cs_rec_flg = 0;
         }
         if (defined("USE_KUROBON")) {
             $xml->use_kurobon = USE_KUROBON ? 1 : 0;
         } else {
             $xml->use_kurobon = 0;
         }
         if (defined("FORMER_TIME")) {
             $xml->former_time = FORMER_TIME;
         } else {
             $xml->former_time = 20;
         }
         if (defined("EXTRA_TIME")) {
             $xml->extra_time = EXTRA_TIME;
         } else {
             $xml->extra_time = 0;
         }
         if (defined("FORCE_CONT_REC")) {
             $xml->force_cont_rec = FORCE_CONT_REC ? 1 : 0;
         } else {
             $xml->force_cont_rec = 0;
         }
         if (defined("REC_SWITCH_TIME")) {
             $xml->rec_switch_time = REC_SWITCH_TIME;
         } else {
             $xml->rec_switch_time = 5;
         }
         if (defined("USE_THUMBS")) {
             $xml->use_thumbs = USE_THUMBS ? 1 : 0;
         } else {
             $xml->use_thumbs = 0;
         }
         if (defined("MEDIATOMB_UPDATE")) {
             $xml->mediatomb_update = MEDIATOMB_UPDATE ? 1 : 0;
         } else {
             $xml->mediatomb_update = 0;
         }
         if (defined("FILENAME_FORMAT")) {
             $xml->filename_format = FILENAME_FORMAT;
         } else {
             $xml->filename_format = "%TYPE%%CH%_%ST%_%ET%";
         }
         if (defined("DB_HOST")) {
             $xml->db_host = DB_HOST;
         } else {
             $xml->db_host = "localhost";
         }
         if (defined("DB_NAME")) {
             $xml->db_name = DB_NAME;
         } else {
             $xml->db_name = "yourdbname";
         }
         if (defined("DB_USER")) {
             $xml->db_user = DB_USER;
         } else {
             $xml->db_user = "******";
         }
         if (defined("DB_PASS")) {
             $xml->db_pass = DB_PASS;
         } else {
             $xml->db_pass = "******";
         }
         if (defined("TBL_PREFIX")) {
             $xml->tbl_prefix = TBL_PREFIX;
         } else {
             $xml->tbl_prefix = "Recorder_";
         }
         if (defined("EPGDUMP")) {
             $xml->epgdump = EPGDUMP;
         } else {
             $xml->epgdump = "/usr/local/bin/epgdump";
         }
         if (defined("AT")) {
             $xml->at = AT;
         } else {
             $xml->at = "/usr/bin/at";
         }
         if (defined("ATRM")) {
             $xml->atrm = ATRM;
         } else {
             $xml->atrm = "/usr/bin/atrm";
         }
         if (defined("SLEEP")) {
             $xml->sleep = SLEEP;
         } else {
             $xml->sleep = "/bin/sleep";
         }
         if (defined("FFMPEG")) {
             $xml->ffmpeg = FFMPEG;
         } else {
             $xml->ffmpeg = "/usr/bin/ffmpeg";
         }
         if (defined("TEMP_DATA")) {
             $xml->temp_data = TEMP_DATA;
         } else {
             $xml->temp_data = "/tmp/__temp.ts";
         }
         if (defined("TEMP_XML")) {
             $xml->temp_xml = TEMP_XML;
         } else {
             $xml->temp_xml = "/tmp/__temp.xml";
         }
         // index.phpで使う設定値
         // 表示する番組表の長さ(時間)
         $xml->program_length = 8;
         // 1局の幅
         $xml->ch_set_width = 150;
         // 1分あたりの高さ
         $xml->height_per_hour = 120;
         // 8月14日版以降に追加した設定項目
         // キーワード自動録画の録画モード
         $xml->autorec_mode = 0;
         $xml->save();
         return $xml;
     }
 }
 /**
  * Relocates this component (copy or move)
  * 
  * This does the following tasks
  * - Remove all DB entries for this component if moved
  * - Relocate the component in filesystem
  * - Fix namespaces of PHP class files
  * - Alter or copy pages
  * - Create DB entries for new component
  * - Activate new component
  * @todo Test copy of pages (rxqcmv1)
  * @param string $newName New component name
  * @param string $newType New component type, one of 'core', 'core_module' and 'module'
  * @param boolean $customized Copy/move to customizing folder?
  * @param boolean $copy Copy or move? True means copy, default is move
  * @return ReflectionComponent New resulting component
  */
 protected function internalRelocate($newName, $newType, $customized, $copy)
 {
     // create new ReflectionComponent
     $newComponent = new self($newName, $newType);
     if ($newComponent->exists()) {
         throw new SystemComponentException('The target component is already Exists. Please provide different component name or use uninstall command to remove old component..');
     }
     // move or copy pages before removing DB entries
     $em = \Env::get('cx')->getDb()->getEntityManager();
     $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     $pages = $pageRepo->findBy(array('module' => $this->componentName));
     $migratedNodes = array();
     foreach ($pages as $page) {
         if ($copy) {
             $node = $page->getNode();
             if (!in_array($node->getId(), $migratedNodes)) {
                 // copy the node and persist changes
                 $newNode = $node->copy();
                 $em->flush();
                 // update module name of the page
                 foreach ($newNode->getPages() as $newPage) {
                     $newPage->setModule($newName);
                     $em->persist($newPage);
                 }
                 $migratedNodes[] = $node->getId();
             }
         } else {
             $page->setModule($newName);
             $em->persist($page);
         }
     }
     $em->flush();
     $this->internalCopyData($newComponent);
     // remove old component from db (component, modules, backend_areas)
     if (!$copy) {
         $this->removeFromDb();
     }
     // copy/move in filesystem (name, type and customizing)
     $newLocation = $newComponent->getDirectory(false, $customized);
     $this->internalFsRelocate($newLocation, $copy);
     // fix namespaces
     $baseDir = ASCMS_DOCUMENT_ROOT;
     if ($copy) {
         $baseDir = $newComponent->getDirectory();
     }
     $newComponent->fixNamespaces(SystemComponent::getBaseNamespaceForType($this->componentType) . '\\' . $this->componentName, $baseDir);
     $newComponent->fixLanguagePlaceholders(strtoupper($this->componentType . '_' . $this->componentName), $baseDir);
     $newComponent->fixDocBlocks(strtolower($this->componentType . '_' . $this->componentName), $baseDir);
     // renaming the component in backend navigation does not yet work
     //$newComponent->setComponentName($baseDir);
     // add new component to db and activate it (component, modules, backend_areas, pages)
     $newComponent->activate();
     return $newComponent;
 }
 /**
  * Obtain the 'base table' name corresponding to the current table.
  * will be thrown
  * - if the current table does not exist.
  * - if the current table is not a 'properties table'
  * - if there is no corresponding 'base table'
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return string
  */
 public function getBaseTable()
 {
     $returnValue = (string) '';
     $name = $this->getName();
     if ($this->isPropertiesTable()) {
         $baseTableName = preg_replace("/props\$/i", '', $name);
         $tblmgr = new self($baseTableName);
         if ($tblmgr->exists()) {
             $returnValue = $baseTableName;
         } else {
             throw new Exception("The 'base table' '{$baseTableName}' does not exist.");
         }
     } else {
         throw new Exception("The current table '{$name}' is not a 'properties table'.");
     }
     return (string) $returnValue;
 }
Example #11
0
 /**
  * Rename a page
  *
  * @param   string  $newpagename New page name
  * @return  boolean True on success, False on error
  */
 public function rename($newpagename)
 {
     // Are they just changing case of characters?
     if (!trim($newpagename)) {
         $this->setError(Lang::txt('No new name provided.'));
         return false;
     }
     $newpagename = $this->_tbl->normalize($newpagename);
     // Are they just changing case of characters?
     if (strtolower($this->get('pagename')) == strtolower($newpagename)) {
         $this->setError(Lang::txt('New name matches old name.'));
         return false;
     }
     // Check that no other pages are using the new title
     $p = new self($newpagename, $this->get('scope'));
     if ($p->exists()) {
         $this->setError(Lang::txt('COM_WIKI_ERROR_PAGE_EXIST') . ' ' . Lang::txt('CHOOSE_ANOTHER_PAGENAME'));
         return false;
     }
     $this->set('pagename', $newpagename);
     if (!$this->store(true, 'page_renamed')) {
         return false;
     }
     return true;
 }
Example #12
0
 public static function checkPostByDescription($description)
 {
     $post = new self();
     $post->where(['description' => $description])->get(1);
     return $post->exists();
 }