/** * Update default page setting * * @access private */ private function update() { if (VPost::update(false)) { try { $array = array('type' => '', 'view' => ''); if ($this->_setting->_data['type'] != VPost::type()) { $array['view'] = 'all'; } else { $array['view'] = VPost::view(); } $array['type'] = VPost::type(); $this->_setting->_data = json_encode($array); $this->_setting->update('_data', 'str'); $this->_setting->_data = json_decode($this->_setting->_data, true); Session::monitor_activity('changed default page setting'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } }
/** * Update setting * * @access private */ private function update() { if (VPost::update_setting(false)) { try { $array = VPost::settings(array('media' => false)); $settings = array('media' => false); foreach ($settings as $key => &$value) { if (in_array($key, $array)) { $value = true; } } $this->_setting->_data = json_encode($settings); $this->_setting->update('_data', 'str'); $this->_setting->_data = json_decode($this->_setting->_data, true); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } }
/** * Update priority links attribute * * @access private */ private function update() { if (VPost::change(false) && in_array(VPost::change_priority(), range(1, 5)) && Vpost::link_id()) { try { foreach (VPost::link_id() as $id) { $link = new Link(); $link->_id = $id; $link->_priority = VPost::change_priority(); $link->update('_priority', 'int'); $this->_action_msg = ActionMessages::updated($link->_result_action); } } catch (Exception $e) { $this->_action_msg = ActionMessages::custom_wrong($e->getMessage()); } } }
/** * Update medias metadata, and also file manipulation when requested * * @access private */ private function update() { if (VPost::update_image(false)) { try { $media = new Media(); $media->_id = VPost::id(); $media->_name = VPost::name(); $media->_description = VPost::description(); $media->update('_name', 'str'); $media->update('_description', 'str'); if (VPost::rotate() != 'no') { $media->read('_permalink'); $media->read('_type'); $path = $media->_permalink; $fname = basename($path); $dirname = dirname($path) . '/'; $img = new HandleMedia(); $img->_mime = $media->_type; $img->load(PATH . $path); $img->rotate(VPost::rotate()); $img->load(PATH . $dirname . '1000-' . $fname); $img->rotate(VPost::rotate()); $img->load(PATH . $dirname . '300-' . $fname); $img->rotate(VPost::rotate()); $img->load(PATH . $dirname . '150-' . $fname); $img->rotate(VPost::rotate()); } if (VPost::flip() != 'no') { $media->read('_permalink'); $media->read('_type'); $path = $media->_permalink; $fname = basename($path); $dirname = dirname($path) . '/'; $img = new HandleMedia(); $img->_mime = $media->_type; $img->load(PATH . $path); $img->flip(VPost::flip()); $img->load(PATH . $dirname . '1000-' . $fname); $img->flip(VPost::flip()); $img->load(PATH . $dirname . '300-' . $fname); $img->flip(VPost::flip()); $img->load(PATH . $dirname . '150-' . $fname); $img->flip(VPost::flip()); } $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } elseif (VPost::update_video(false)) { try { $media = new Media(); $media->_id = VPost::id(); $media->_name = VPost::name(); $media->_description = VPost::description(); $media->_category = implode(',', VPost::cat(array())); $media->update('_name', 'str'); $media->update('_description', 'str'); $media->update('_category', 'str'); if (VPost::attach() != 'no') { $media->_attachment = VPost::attach(); $media->update('_attachment', 'int'); } else { $media->_attachment = null; $media->update('_attachment', 'null'); } $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } elseif (VPost::update_alien(false)) { try { $media = new Media(); $media->_id = VPost::id(); $media->_name = VPost::name(); $media->_description = VPost::description(); $media->_embed_code = VPost::embed(); $media->update('_name', 'str'); $media->update('_description', 'str'); $media->update('_embed_code', 'str'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } }
/** * Update album and pictures metadatas * * @access private */ private function update() { if (VPost::apply_action(false) && in_array(VPost::action(), array('publish', 'unpublish'))) { switch (VPost::action()) { case 'publish': $status = 'publish'; break; case 'unpublish': $status = 'draft'; break; } if (VPost::album_id()) { try { foreach (VPost::album_id() as $id) { $album = new Media(); $album->_id = $id; $album->_status = $status; $album->update('_status', 'str'); } $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } } elseif (VPost::save(false)) { try { $album = new Media(); $album->_id = VPost::album_id(); $album->_name = VPost::name(); $album->_description = VPost::description(); $album->_allow_comment = VPost::allow_comment('closed'); $album->_category = implode(',', VPost::cat(array())); $album->update('_name', 'str'); $album->update('_description', 'str'); $album->update('_allow_comment', 'str'); $album->update('_category', 'str'); foreach ($_POST as $key => $value) { $pic = substr($key, 0, 3); if ($pic == 'pic') { $id = substr($key, 3); $picture = new Media(); $picture->_id = $id; $picture->_name = VPost::$key(); $picture->update('_name', 'str'); } } $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } elseif (VPost::publish(false)) { try { $album = new Media(); $album->_id = VPost::album_id(); $album->_status = 'publish'; $album->_name = VPost::name(); $album->_description = VPost::description(); $album->_allow_comment = VPost::allow_comment('closed'); $album->_category = implode(',', VPost::cat(array())); $album->update('_name', 'str'); $album->update('_description', 'str'); $album->update('_allow_comment', 'str'); $album->update('_category', 'str'); $album->update('_status', 'str'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } elseif (VPost::unpublish(false)) { try { $album = new Media(); $album->_id = VPost::album_id(); $album->_status = 'draft'; $album->update('_status', 'str'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } elseif (VPost::update_image(false)) { try { $media = new Media(); $media->_id = VPost::pid(); $media->_name = VPost::name(); $media->_description = VPost::description(); $media->update('_name', 'str'); $media->update('_description', 'str'); if (VPost::rotate() != 'no') { $media->read('_permalink'); $media->read('_type'); $path = $media->_permalink; $fname = basename($path); $dirname = dirname($path) . '/'; $img = new HandleMedia(); $img->_mime = $media->_type; $img->load(PATH . $path); $img->rotate(VPost::rotate()); $img->load(PATH . $dirname . '1000-' . $fname); $img->rotate(VPost::rotate()); $img->load(PATH . $dirname . '300-' . $fname); $img->rotate(VPost::rotate()); $img->load(PATH . $dirname . '150-' . $fname); $img->rotate(VPost::rotate()); } if (VPost::flip() != 'no') { $media->read('_permalink'); $media->read('_type'); $path = $media->_permalink; $fname = basename($path); $dirname = dirname($path) . '/'; $img = new HandleMedia(); $img->_mime = $media->_type; $img->load(PATH . $path); $img->flip(VPost::flip()); $img->load(PATH . $dirname . '1000-' . $fname); $img->flip(VPost::flip()); $img->load(PATH . $dirname . '300-' . $fname); $img->flip(VPost::flip()); $img->load(PATH . $dirname . '150-' . $fname); $img->flip(VPost::flip()); } $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } }
/** * Update setting * * @access private */ private function update() { if (VPost::update_setting(false)) { try { $this->_setting->_data = json_encode(VPost::networks(array())); $this->_setting->update('_data', 'str'); $this->_setting->_data = json_decode($this->_setting->_data, true); $result = true; } catch (Exception $e) { $resut = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } }
/** * Update all roles at one time * * @access private */ private function update() { if (VPost::update_roles(false)) { try { $setting =& Roles::load(); $to_read['table'] = 'setting'; $to_read['columns'] = array('SETTING_ID'); $to_read['condition_columns'][':t'] = 'setting_type'; $to_read['condition_select_types'][':t'] = '='; $to_read['condition_values'][':t'] = 'role'; $to_read['value_types'][':t'] = 'str'; $to_read['condition_types'][':n'] = 'AND'; $to_read['condition_columns'][':n'] = 'setting_name'; $to_read['condition_select_types'][':n'] = '='; $to_read['value_types'][':n'] = 'str'; foreach ($setting->_roles as $role) { if (!in_array($role, array('administrator', 'editor', 'author'))) { $name = 'auth_' . $role; $array = VPost::$name(array()); $auth = array('dashboard' => false, 'post' => false, 'media' => false, 'album_photo' => false, 'comments' => false, 'delete_content' => false, 'settings' => false); foreach ($auth as $key => &$value) { if (in_array($key, $array)) { $value = true; } } $to_read['condition_values'][':n'] = $role; $role = $this->_db->read($to_read); $role = new Setting($role[0]['SETTING_ID']); $role->_data = json_encode($auth); $role->update('_data', 'str'); } } $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::updated($result); } }